Skip to main content

Serialize

Derive Macro Serialize 

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

Derive pack_io::Serialize for a struct or enum.

Fields are encoded in their declaration order. For enums, a varint(variant_index) is emitted first, followed by the variant’s fields. The generated impl also overrides encoded_len with direct arithmetic.

Each encoded field type must implement pack_io::Serialize (or be handled by a #[pack_io(with = "...")] module). See the crate docs for the attribute table.