derive_codec_sv2

Crates.ioderive_codec_sv2
lib.rsderive_codec_sv2
version1.1.1
created_at2021-06-14 16:55:57.124643+00
updated_at2024-12-27 17:36:04.51344+00
descriptionDerive macro for Sv2 binary format serializer and deserializer
homepagehttps://stratumprotocol.org
repositoryhttps://github.com/stratum-mining/stratum
max_upload_size
id409998
size30,685
SV2-bot (SV2-bot)

documentation

https://docs.rs/derive_codec_sv2

README

derive_codec_sv2

crates.io docs.rs rustc+ license codecov

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 GetSize trait, helpful for dynamic protocol message framing.

Usage

To include this crate in your project, run:

cargo add derive-codec-sv2
Commit count: 3337

cargo fmt