Skip to content

Commit 4890909

Browse files
committed
113 Add Permissive Serializer.
1 parent 8dd9efd commit 4890909

File tree

4 files changed

+196
-49
lines changed

4 files changed

+196
-49
lines changed

src/ondisk.rs

+46-41
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,28 @@ macro_rules! make_bitfield_serde {(
12711271
)*
12721272
}
12731273
}
1274+
1275+
#[cfg(feature = "serde")]
1276+
paste::paste!{
1277+
/// Use this for serialization in order to make serde skip those
1278+
/// fields where the meaning of a raw value is unknown to us.
1279+
///
1280+
/// Caller can then override Serializer::skip_field and thus find out
1281+
/// which fields were skipped, inferring where errors were.
1282+
#[doc(hidden)]
1283+
#[allow(non_camel_case_types)]
1284+
#[cfg_attr(feature = "serde", derive(Serialize))]
1285+
#[cfg_attr(feature = "serde", serde(rename = "" $StructName))]
1286+
pub(crate) struct [<SerdePermissiveSerializing $StructName>] {
1287+
$(
1288+
$(#[serde(skip_serializing_if="Option::is_none")]
1289+
pub $field_name: Option<$field_ty>,)?
1290+
$(#[serde(skip_serializing_if="Option::is_none")]
1291+
$(#[$serde_field_orig_meta])*
1292+
pub $field_name: Option<$serde_ty>,)?
1293+
)*
1294+
}
1295+
}
12741296
}}
12751297

12761298
make_bitfield_serde! {
@@ -2657,21 +2679,11 @@ pub mod memory {
26572679
#[repr(u32)]
26582680
#[derive(Clone, Copy)]
26592681
pub struct RdimmDdr4Voltages {
2660-
pub _1_2V || #[serde(default)] bool : bool | pub get bool : pub set bool,
2682+
pub _1_2V || #[serde(default)] #[serde(rename = "1.2 V")] bool : bool | pub get bool : pub set bool,
26612683
pub _reserved_1 || #[serde(default)] SerdeHex32 : B31,
26622684
// all = 7
26632685
}
26642686
}
2665-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2666-
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
2667-
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
2668-
#[cfg_attr(feature = "serde", serde(rename = "RdimmDdr4Voltages"))]
2669-
pub struct CustomSerdeRdimmDdr4Voltages {
2670-
#[cfg_attr(feature = "serde", serde(rename = "1.2 V"))]
2671-
pub _1_2V: bool,
2672-
#[cfg_attr(feature = "serde", serde(default))]
2673-
pub _reserved_1: u32,
2674-
}
26752687
macro_rules! define_compat_bitfield_field {
26762688
($compat_field:ident, $current_field:ident) => {
26772689
paste! {
@@ -2820,27 +2832,13 @@ pub mod memory {
28202832
#[repr(u32)]
28212833
#[derive(Clone, Copy)]
28222834
pub struct UdimmDdr4Voltages {
2823-
pub _1_5V || #[serde(default)] bool : bool | pub get bool : pub set bool,
2824-
pub _1_35V || #[serde(default)] bool : bool | pub get bool : pub set bool,
2825-
pub _1_25V || #[serde(default)] bool : bool | pub get bool : pub set bool,
2835+
pub _1_5V || #[serde(default)] #[serde(rename = "1.5 V")] bool : bool | pub get bool : pub set bool,
2836+
pub _1_35V || #[serde(default)] #[serde(rename = "1.35 V")] bool : bool | pub get bool : pub set bool,
2837+
pub _1_25V || #[serde(default)] #[serde(rename = "1.25 V")] bool : bool | pub get bool : pub set bool,
28262838
// all = 7
28272839
pub _reserved_1 || #[serde(default)] SerdeHex32 : B29,
28282840
}
28292841
}
2830-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2831-
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
2832-
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
2833-
#[cfg_attr(feature = "serde", serde(rename = "UdimmDdr4Voltages"))]
2834-
pub struct CustomSerdeUdimmDdr4Voltages {
2835-
#[cfg_attr(feature = "serde", serde(rename = "1.5 V"))]
2836-
pub _1_5V: bool,
2837-
#[cfg_attr(feature = "serde", serde(rename = "1.35 V"))]
2838-
pub _1_35V: bool,
2839-
#[cfg_attr(feature = "serde", serde(rename = "1.25 V"))]
2840-
pub _1_25V: bool,
2841-
#[cfg_attr(feature = "serde", serde(default))]
2842-
pub _reserved_1: u32,
2843-
}
28442842
impl UdimmDdr4Voltages {
28452843
define_compat_bitfield_field!(v_1_5, _1_5V);
28462844
define_compat_bitfield_field!(v_1_35, _1_35V);
@@ -2915,21 +2913,11 @@ pub mod memory {
29152913
#[repr(u32)]
29162914
#[derive(Clone, Copy)]
29172915
pub struct LrdimmDdr4Voltages {
2918-
pub _1_2V || #[serde(default)] bool : bool | pub get bool : pub set bool,
2916+
pub _1_2V || #[serde(default)] #[serde(rename = "1.2 V")] bool : bool | pub get bool : pub set bool,
29192917
// all = 7
29202918
pub _reserved_1 || #[serde(default)] SerdeHex32 : B31,
29212919
}
29222920
}
2923-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2924-
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
2925-
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
2926-
#[cfg_attr(feature = "serde", serde(rename = "LrdimmDdr4Voltages"))]
2927-
pub struct CustomSerdeLrdimmDdr4Voltages {
2928-
#[cfg_attr(feature = "serde", serde(rename = "1.2 V"))]
2929-
pub _1_2V: bool,
2930-
#[cfg_attr(feature = "serde", serde(default))]
2931-
pub _reserved_1: u32,
2932-
}
29332921

29342922
impl LrdimmDdr4Voltages {
29352923
define_compat_bitfield_field!(v_1_2, _1_2V);
@@ -3843,7 +3831,7 @@ pub mod memory {
38433831
}
38443832
}
38453833
#[cfg(feature = "serde")]
3846-
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3834+
#[cfg_attr(feature = "serde", derive(Deserialize))]
38473835
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
38483836
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
38493837
#[cfg_attr(feature = "serde", serde(rename = "ErrorOutControlBeepCode"))]
@@ -3853,6 +3841,14 @@ pub mod memory {
38533841
pub peak_attr: ErrorOutControlBeepCodePeakAttr,
38543842
}
38553843
#[cfg(feature = "serde")]
3844+
#[cfg_attr(feature = "serde", derive(Serialize))]
3845+
#[cfg_attr(feature = "serde", serde(rename = "ErrorOutControlBeepCode"))]
3846+
pub(crate) struct CustomSerdePermissiveSerializingErrorOutControlBeepCode {
3847+
pub custom_error_type: Option<ErrorOutControlBeepCodeErrorType>,
3848+
pub peak_map: Option<SerdeHex16>,
3849+
pub peak_attr: Option<ErrorOutControlBeepCodePeakAttr>,
3850+
}
3851+
#[cfg(feature = "serde")]
38563852
impl ErrorOutControlBeepCode {
38573853
pub(crate) fn serde_custom_error_type(
38583854
&self,
@@ -4330,7 +4326,7 @@ Clone)]
43304326
}
43314327

43324328
#[cfg(feature = "serde")]
4333-
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4329+
#[cfg_attr(feature = "serde", derive(Deserialize))]
43344330
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
43354331
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
43364332
#[cfg_attr(
@@ -4341,6 +4337,15 @@ Clone)]
43414337
pub raw_body: DdrPostPackageRepairBody,
43424338
}
43434339
#[cfg(feature = "serde")]
4340+
#[cfg_attr(feature = "serde", derive(Serialize))]
4341+
#[cfg_attr(
4342+
feature = "serde",
4343+
serde(rename = "DdrPostPackageRepairElement")
4344+
)]
4345+
pub struct CustomSerdePermissiveSerializingDdrPostPackageRepairElement {
4346+
pub raw_body: Option<DdrPostPackageRepairBody>,
4347+
}
4348+
#[cfg(feature = "serde")]
43444349
impl DdrPostPackageRepairElement {
43454350
pub(crate) fn serde_raw_body(
43464351
&self,

0 commit comments

Comments
 (0)