Decode

Derive Macro Decode 

Source
#[derive(Decode)]
{
    // Attributes available to this derive:
    #[senax]
}
Expand description

Derive macro for implementing the Decode trait

This procedural macro automatically generates an implementation of the Decode trait for structs and enums. It supports various field attributes for customizing the decoding behavior and provides forward/backward compatibility.

§Supported Attributes

§Container-level attributes:

  • #[senax(disable_encode)] - Generate stub implementation (unimplemented!() only) for Encode/Decode

§Field-level attributes:

  • #[senax(id=N)] - Set explicit field/variant ID
  • #[senax(default)] - Use default value if field is missing
  • #[senax(skip_decode)] - Skip field during decoding (use default value)
  • #[senax(skip_default)] - Use default value if field is missing (same as default for decode)
  • #[senax(rename="name")] - Use alternative name for ID calculation

§Examples

#[derive(Decode)]
struct MyStruct {
    #[senax(id=1)]
    field1: i32,
    #[senax(default)]
    field2: String,
    #[senax(skip_decode)]
    field3: bool,
}

// Stub implementation for faster compilation during development
#[derive(Encode, Decode)]
#[senax(disable_encode)]
struct UnfinishedStruct {
    #[senax(id=1)]
    field1: i32,
}