|
|
@ -1,4 +1,4 @@
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde::{Deserialize, Deserializer, Serialize};
|
|
|
|
use serde_json::Value;
|
|
|
|
use serde_json::Value;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::path::PathBuf;
|
|
|
@ -311,7 +311,8 @@ pub struct Variable {
|
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
|
|
|
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
#[serde(rename_all = "camelCase")]
|
|
|
|
pub struct Module {
|
|
|
|
pub struct Module {
|
|
|
|
pub id: String, // TODO: || number
|
|
|
|
#[serde(deserialize_with = "from_number")]
|
|
|
|
|
|
|
|
pub id: String,
|
|
|
|
pub name: String,
|
|
|
|
pub name: String,
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
|
|
pub path: Option<PathBuf>,
|
|
|
|
pub path: Option<PathBuf>,
|
|
|
@ -331,6 +332,23 @@ pub struct Module {
|
|
|
|
pub address_range: Option<String>,
|
|
|
|
pub address_range: Option<String>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn from_number<'de, D>(deserializer: D) -> Result<String, D::Error>
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
|
|
|
#[serde(untagged)]
|
|
|
|
|
|
|
|
enum NumberOrString {
|
|
|
|
|
|
|
|
Number(i64),
|
|
|
|
|
|
|
|
String(String),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
match NumberOrString::deserialize(deserializer)? {
|
|
|
|
|
|
|
|
NumberOrString::Number(n) => Ok(n.to_string()),
|
|
|
|
|
|
|
|
NumberOrString::String(s) => Ok(s),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub mod requests {
|
|
|
|
pub mod requests {
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
|
|
|
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
|
|
@ -887,4 +905,18 @@ pub mod events {
|
|
|
|
pub offset: usize,
|
|
|
|
pub offset: usize,
|
|
|
|
pub count: usize,
|
|
|
|
pub count: usize,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_deserialize_module_id_from_number() {
|
|
|
|
|
|
|
|
let raw = r#"{"id": 0, "name": "Name"}"#;
|
|
|
|
|
|
|
|
let module: super::Module = serde_json::from_str(raw).expect("Error!");
|
|
|
|
|
|
|
|
assert_eq!(module.id, "0");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn test_deserialize_module_id_from_string() {
|
|
|
|
|
|
|
|
let raw = r#"{"id": "0", "name": "Name"}"#;
|
|
|
|
|
|
|
|
let module: super::Module = serde_json::from_str(raw).expect("Error!");
|
|
|
|
|
|
|
|
assert_eq!(module.id, "0");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|