Derive macros for neopack Pack and Unpack traits.
Structs
Named structs encode as a neopack List of fields in declaration order.
#[derive(Pack, Unpack)]
struct Point { x: f64, y: f64 }
Enums
Each variant encodes as a neopack Variant with the variant name as the tag.
- Unit: payload is
unit() - Single field: payload is the field directly
- Multiple fields: payload is a List of fields
#[derive(Pack, Unpack)]
enum Shape {
Empty,
Circle(f64),
Rect { w: f64, h: f64 },
}
Attributes
#[pack(bytes)] on a Vec<u8> or [u8; N] field encodes as a byte blob
instead of a list of u8 tags.