Skip to main content

DeserializeView

Derive Macro DeserializeView 

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

Derive pack_io::DeserializeView for a struct or enum (zero-copy decode).

The type MUST have exactly one lifetime parameter — used as the borrow of the underlying input buffer. Field types must implement pack_io::DeserializeView<'that_lifetime>. The built-in impls for primitives, &'a str, &'a [u8], and the standard Option / Result / tuple / array types cover the common cases.

Enums use the same varint(variant_index) ++ fields wire shape as #[derive(Deserialize)]; the only difference is each variant’s fields are decoded via DeserializeView so borrow-shaped fields land as &'a str / &'a [u8] rather than String / Vec<u8>.