Installation
Don't depend on pack-io-derive directly. Depend on pack-io with the derive feature:
[]
= { = "1", = ["derive"] }
What the macros do
Three derives, all working on structs (named-field, tuple, unit) and enums (any variant shape), generic over type parameters:
use ;
| Derive | Implements | Notes |
|---|---|---|
Serialize |
pack_io::Serialize |
Generic over the pack_io::Encode behaviour trait. |
Deserialize |
pack_io::Deserialize |
Generic over the pack_io::Decode behaviour trait. Owning decode. |
DeserializeView |
pack_io::DeserializeView<'a> |
Zero-copy. Struct must have exactly one lifetime parameter. |
Generated code is generic over Encode / Decode, so the same impl drives both the in-memory codec and the streaming IoEncoder<W> / IoDecoder<R> in the parent crate.
Field order in the source code is the encoded byte order. For enums, a varint(variant_index) prefix is emitted first, in source-declaration order starting at 0. Append new variants to the end of an enum declaration to keep the wire shape backward-compatible — inserting in the middle shifts every later variant's index.
See the full wire-format specification and the API reference in the parent repository.
Compatibility
- MSRV: Rust 1.85 (2024 edition).
- Version pinning:
pack-iodepends onpack-io-derivewith an exact=X.Y.Zconstraint so mismatched derive output cannot leak acrosspack-iorevisions.