Skip to content

Commit

Permalink
add docs for derive-codec-sv2 module
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourya742 committed Oct 26, 2024
1 parent 8a99d2a commit 46b0674
Show file tree
Hide file tree
Showing 3 changed files with 479 additions and 110 deletions.
6 changes: 5 additions & 1 deletion protocols/v2/binary-sv2/no-serde-sv2/derive_codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ binary_codec_sv2 = {version = "^1.0.0", path="../codec"}
[lib]
proc-macro = true

[dev-dependencies]
proc-macro2 = "1.0.89"
quote = "1.0.37"

[package.metadata.docs.rs]
all-features = true
all-features = true
22 changes: 22 additions & 0 deletions protocols/v2/binary-sv2/no-serde-sv2/derive_codec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# derive-codec-sv2

[![crates.io](https://img.shields.io/crates/v/derive-codec-sv2.svg)](https://crates.io/crates/derive-codec-sv2)
[![docs.rs](https://docs.rs/derive-codec-sv2/badge.svg)](https://docs.rs/derive-codec-sv2)
[![rustc+](https://img.shields.io/badge/rustc-1.75.0%2B-lightgrey.svg)](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/stratum-mining/stratum/blob/main/LICENSE.md)

`derive-codec-sv2` is a 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:

```sh
cargo add derive-codec-sv2
Loading

0 comments on commit 46b0674

Please sign in to comment.