Skip to main content

Decode

Derive Macro Decode 

Source
#[derive(Decode)]
{
    // Attributes available to this derive:
    #[msgpack]
}
Available on crate feature derive only.
Expand description

Derive the DecodeBorrowed trait for a struct.

Named-field structs accept both map and array MessagePack formats on decode regardless of the map/array attribute.

§Supported types

  • Named-field structs — decoded from a MessagePack map or array
  • Tuple structs — decoded from a MessagePack array
  • Unit structs — decoded from MessagePack nil

§Container attributes

  • #[msgpack(map)] — default for named-field structs
  • #[msgpack(array)] — encode mode; requires key on every field

§Field attributes

  • #[msgpack(key = N)] — array index (required in array mode)
  • #[msgpack(bytes)] — decode the field from MessagePack binary
  • #[msgpack(decode_with = "path::to::fn")] — custom decode function