tracel-ai/burn · error

struct variant is not implemented because it is not used in

Error message

struct variant is not implemented because it is not used in the burn module

What it means

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.

Source

Thrown at crates/burn-store/src/nested/de.rs:724

        }
    }

    fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'de>,
    {
        unimplemented!("tuple variant is not implemented because it is not used in the burn module")
    }

    fn struct_variant<V>(
        self,
        _fields: &'static [&'static str],
        _visitor: V,
    ) -> Result<V::Value, Self::Error>
    where
        V: Visitor<'de>,
    {
        unimplemented!(
            "struct variant is not implemented because it is not used in the burn module"
        )
    }
}

/// A wrapper for the nested value data structure with a burn module adapter.
struct NestedValueWrapper<A: BurnModuleAdapter> {
    value: NestedValue,
    default_for_missing_fields: bool,
    phantom: std::marker::PhantomData<A>,
}

impl<A: BurnModuleAdapter> NestedValueWrapper<A> {
    fn new(value: NestedValue, default_for_missing_fields: bool) -> Self {
        Self {
            value,
            default_for_missing_fields,
            phantom: std::marker::PhantomData,

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Flatten struct variants into plain structs or unit variants
  2. Use a tagged representation the adapter supports, or avoid enums entirely in records loaded via nested de
  3. Patch the adapter to implement struct_variant by forwarding to the visitor's visit_map
  4. Deserialize such types with a standard serde backend instead

Example fix

// before
enum Config { Inner { size: usize } }

// after
struct Config { inner: InnerConfig }
struct InnerConfig { size: usize }
Defensive patterns

Strategy: validation

Validate before calling

#[cfg(test)]
#[test]
fn roundtrip_record() {
    let r = MyRecord::default();
    let back: MyRecord = from_nested(to_nested(&r).unwrap()).unwrap();
}

Try / catch

std::panic::catch_unwind(|| MyType::deserialize(nested))
    .unwrap_or_else(|_| deserialize_with_serde_json()),

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/5f7a77e0b4a44a57. Report an issue: GitHub.