{"record":{"id":"5f7a77e0b4a44a57","repo":"tracel-ai/burn","slug":"struct-variant-is-not-implemented-because-it-is-no","errorCode":null,"errorMessage":"struct variant is not implemented because it is not used in the burn module","messagePattern":"struct variant is not implemented because it is not used in the burn module","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-store/src/nested/de.rs","lineNumber":724,"sourceCode":"        }\n    }\n\n    fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\"tuple variant is not implemented because it is not used in the burn module\")\n    }\n\n    fn struct_variant<V>(\n        self,\n        _fields: &'static [&'static str],\n        _visitor: V,\n    ) -> Result<V::Value, Self::Error>\n    where\n        V: Visitor<'de>,\n    {\n        unimplemented!(\n            \"struct variant is not implemented because it is not used in the burn module\"\n        )\n    }\n}\n\n/// A wrapper for the nested value data structure with a burn module adapter.\nstruct NestedValueWrapper<A: BurnModuleAdapter> {\n    value: NestedValue,\n    default_for_missing_fields: bool,\n    phantom: std::marker::PhantomData<A>,\n}\n\nimpl<A: BurnModuleAdapter> NestedValueWrapper<A> {\n    fn new(value: NestedValue, default_for_missing_fields: bool) -> Self {\n        Self {\n            value,\n            default_for_missing_fields,\n            phantom: std::marker::PhantomData,","sourceCodeStart":706,"sourceCodeEnd":742,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-store/src/nested/de.rs#L706-L742","documentation":"Same family as the other stubs in burn-store's nested VariantAccess: struct variants are declared unsupported because burn's module serialization never produces them. Any Deserialize impl that calls deserialize_struct_variant on this deserializer panics immediately.","triggerScenarios":"Deserializing a type with an enum that uses struct variants (externally tagged, e.g. `enum E { A { x: u32 } }`) through the nested value deserializer in burn-store.","commonSituations":"Model or config types containing struct-variant enums being round-tripped through burn-store nested records; typically appears after introducing such an enum into a serialized struct.","solutions":["Flatten struct variants into plain structs or unit variants","Use a tagged representation the adapter supports, or avoid enums entirely in records loaded via nested de","Patch the adapter to implement struct_variant by forwarding to the visitor's visit_map","Deserialize such types with a standard serde backend instead"],"exampleFix":"// before\nenum Config { Inner { size: usize } }\n\n// after\nstruct Config { inner: InnerConfig }\nstruct InnerConfig { size: usize }","handlingStrategy":"validation","validationCode":"#[cfg(test)]\n#[test]\nfn roundtrip_record() {\n    let r = MyRecord::default();\n    let back: MyRecord = from_nested(to_nested(&r).unwrap()).unwrap();\n}","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| MyType::deserialize(nested))\n    .unwrap_or_else(|_| deserialize_with_serde_json()),","preventionTips":["Avoid struct-variant enums in types deserialized via burn nested de","Flatten enums into explicit struct fields","Cover every record type with round-trip tests"],"tags":["rust","serde","deserialization","burn"],"backgroundTag":"unimplemented-serde-deserializer","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}