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).

A type with exactly one lifetime parameter gets impl DeserializeView<'that_lifetime>: its &'a str / &'a [u8] fields borrow from the input buffer. A type with no lifetime parameter gets an impl for every lifetime, so owned helper types (headers, ids, enums of scalars) can be nested inside borrowing views. More than one lifetime parameter is rejected.

Field types must implement pack_io::DeserializeView<'_>. The wire shape, including #[pack_io(version = N)] frames, is identical to #[derive(Deserialize)].