#[derive(Encode)]
{
// Attributes available to this derive:
#[field]
#[variant]
}
Expand description
Derives the Encode trait for a struct or enum.
For structs, encodes each field in declaration order. Field attributes control encoding behavior (varint, optional, length-prefixed, rest).
For enums, writes a VarInt discriminant followed by the variant’s fields.
Discriminants are sequential from 0 unless overridden with #[variant(id)].
For packet structs, use #[packet(id = N)] instead — it generates
Encode, Decode, EncodedSize, and PACKET_ID all at once.