1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pub mod binary_version;
pub mod schema_version;
pub use binary_version::BinaryVersion;
pub use schema_version::SchemaVersion;
use crate::{
data_tree::Reflection,
size::{Blocks, Bytes},
};
use derive_more::{From, TryInto};
#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, From, TryInto)]
#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "json", serde(tag = "unit", content = "tree"))]
#[cfg_attr(feature = "json", serde(rename_all = "kebab-case"))]
pub enum UnitAndTree {
Bytes(Reflection<String, Bytes>),
Blocks(Reflection<String, Blocks>),
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "json", serde(rename_all = "kebab-case"))]
pub struct JsonData {
pub schema_version: SchemaVersion,
#[cfg_attr(feature = "json", serde(rename = "pdu"))]
pub binary_version: Option<BinaryVersion>,
#[cfg_attr(feature = "json", serde(flatten))]
pub unit_and_tree: UnitAndTree,
}