derive_codec_sv2
derive-codec-sv2 is a no-std Rust crate offering procedural macros for automating serialization and deserialization of structs used within the Sv2 (Stratum V2) protocol. This crate provides Encodable and Decodable macros to streamline binary data handling, especially useful for protocol-level implementations where efficient encoding and decoding are essential.
Key Capabilities
- Automatic Encoding and Decoding: Derives methods for converting structs to and from binary format, reducing boilerplate code for data structures used in Sv2.
- Attribute-Based Configuration: Supports
#[already_sized]attribute for marking fixed-size structs, enabling optimizations in binary handling. - Flexible Field Parsing: Allows parsing of fields with lifetimes, generics, and static references, enhancing compatibility with various protocol requirements.
- Custom Size Calculation: Provides field-specific size calculation through the derived
GetSizetrait, helpful for dynamic protocol message framing.
Usage
To include this crate in your project, run: