Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

113 Add Permissive Serializer. #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 46 additions & 41 deletions src/ondisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,28 @@ macro_rules! make_bitfield_serde {(
)*
}
}

#[cfg(feature = "serde")]
paste::paste!{
/// Use this for serialization in order to make serde skip those
/// fields where the meaning of a raw value is unknown to us.
///
/// Caller can then override Serializer::skip_field and thus find out
/// which fields were skipped, inferring where errors were.
#[doc(hidden)]
#[allow(non_camel_case_types)]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(feature = "serde", serde(rename = "" $StructName))]
pub(crate) struct [<SerdePermissiveSerializing $StructName>] {
$(
$(#[serde(skip_serializing_if="Option::is_none")]
pub $field_name: Option<$field_ty>,)?
$(#[serde(skip_serializing_if="Option::is_none")]
$(#[$serde_field_orig_meta])*
pub $field_name: Option<$serde_ty>,)?
)*
}
}
}}

make_bitfield_serde! {
Expand Down Expand Up @@ -2657,21 +2679,11 @@ pub mod memory {
#[repr(u32)]
#[derive(Clone, Copy)]
pub struct RdimmDdr4Voltages {
pub _1_2V || #[serde(default)] bool : bool | pub get bool : pub set bool,
pub _1_2V || #[serde(default)] #[serde(rename = "1.2 V")] bool : bool | pub get bool : pub set bool,
pub _reserved_1 || #[serde(default)] SerdeHex32 : B31,
// all = 7
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "serde", serde(rename = "RdimmDdr4Voltages"))]
pub struct CustomSerdeRdimmDdr4Voltages {
#[cfg_attr(feature = "serde", serde(rename = "1.2 V"))]
pub _1_2V: bool,
#[cfg_attr(feature = "serde", serde(default))]
pub _reserved_1: u32,
}
macro_rules! define_compat_bitfield_field {
($compat_field:ident, $current_field:ident) => {
paste! {
Expand Down Expand Up @@ -2820,27 +2832,13 @@ pub mod memory {
#[repr(u32)]
#[derive(Clone, Copy)]
pub struct UdimmDdr4Voltages {
pub _1_5V || #[serde(default)] bool : bool | pub get bool : pub set bool,
pub _1_35V || #[serde(default)] bool : bool | pub get bool : pub set bool,
pub _1_25V || #[serde(default)] bool : bool | pub get bool : pub set bool,
pub _1_5V || #[serde(default)] #[serde(rename = "1.5 V")] bool : bool | pub get bool : pub set bool,
pub _1_35V || #[serde(default)] #[serde(rename = "1.35 V")] bool : bool | pub get bool : pub set bool,
pub _1_25V || #[serde(default)] #[serde(rename = "1.25 V")] bool : bool | pub get bool : pub set bool,
// all = 7
pub _reserved_1 || #[serde(default)] SerdeHex32 : B29,
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "serde", serde(rename = "UdimmDdr4Voltages"))]
pub struct CustomSerdeUdimmDdr4Voltages {
#[cfg_attr(feature = "serde", serde(rename = "1.5 V"))]
pub _1_5V: bool,
#[cfg_attr(feature = "serde", serde(rename = "1.35 V"))]
pub _1_35V: bool,
#[cfg_attr(feature = "serde", serde(rename = "1.25 V"))]
pub _1_25V: bool,
#[cfg_attr(feature = "serde", serde(default))]
pub _reserved_1: u32,
}
impl UdimmDdr4Voltages {
define_compat_bitfield_field!(v_1_5, _1_5V);
define_compat_bitfield_field!(v_1_35, _1_35V);
Expand Down Expand Up @@ -2915,21 +2913,11 @@ pub mod memory {
#[repr(u32)]
#[derive(Clone, Copy)]
pub struct LrdimmDdr4Voltages {
pub _1_2V || #[serde(default)] bool : bool | pub get bool : pub set bool,
pub _1_2V || #[serde(default)] #[serde(rename = "1.2 V")] bool : bool | pub get bool : pub set bool,
// all = 7
pub _reserved_1 || #[serde(default)] SerdeHex32 : B31,
}
}
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "serde", serde(rename = "LrdimmDdr4Voltages"))]
pub struct CustomSerdeLrdimmDdr4Voltages {
#[cfg_attr(feature = "serde", serde(rename = "1.2 V"))]
pub _1_2V: bool,
#[cfg_attr(feature = "serde", serde(default))]
pub _reserved_1: u32,
}

impl LrdimmDdr4Voltages {
define_compat_bitfield_field!(v_1_2, _1_2V);
Expand Down Expand Up @@ -3843,7 +3831,7 @@ pub mod memory {
}
}
#[cfg(feature = "serde")]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "serde", serde(rename = "ErrorOutControlBeepCode"))]
Expand All @@ -3853,6 +3841,14 @@ pub mod memory {
pub peak_attr: ErrorOutControlBeepCodePeakAttr,
}
#[cfg(feature = "serde")]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(feature = "serde", serde(rename = "ErrorOutControlBeepCode"))]
pub(crate) struct CustomSerdePermissiveSerializingErrorOutControlBeepCode {
pub custom_error_type: Option<ErrorOutControlBeepCodeErrorType>,
pub peak_map: Option<SerdeHex16>,
pub peak_attr: Option<ErrorOutControlBeepCodePeakAttr>,
}
#[cfg(feature = "serde")]
impl ErrorOutControlBeepCode {
pub(crate) fn serde_custom_error_type(
&self,
Expand Down Expand Up @@ -4330,7 +4326,7 @@ Clone)]
}

#[cfg(feature = "serde")]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", derive(Deserialize))]
#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(
Expand All @@ -4341,6 +4337,15 @@ Clone)]
pub raw_body: DdrPostPackageRepairBody,
}
#[cfg(feature = "serde")]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[cfg_attr(
feature = "serde",
serde(rename = "DdrPostPackageRepairElement")
)]
pub struct CustomSerdePermissiveSerializingDdrPostPackageRepairElement {
pub raw_body: Option<DdrPostPackageRepairBody>,
}
#[cfg(feature = "serde")]
impl DdrPostPackageRepairElement {
pub(crate) fn serde_raw_body(
&self,
Expand Down
Loading