Skip to content

Commit

Permalink
Top mod encoder doc cmts + decoder consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
rrybarczyk committed Sep 10, 2024
1 parent 76f3295 commit 25e159d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
7 changes: 5 additions & 2 deletions protocols/v2/codec-sv2/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
//!
//! ## Types
//!
//! * `WithoutNoise`: Decoder for Sv2 frames without Noise protocol support.
//! * `WithNoise`: Decoder for Sv2 frames with Noise protocol support (requires the `noise_sv2`
//! feature).
//! * `StandardEitherFrame`: Represents an encoded or decoded frame that could be either a regular
//! or Noise-protected frame.
//! * `StandardSv2Frame`: Represents an encoded or decoded Stratum V2 frame.
Expand All @@ -18,8 +21,8 @@
//!
//! ## Usage
//!
//! This module is designed to be used to decode incoming Stratum V2 messages, potentially with
//! Noise protocol encryption for secure communication.
//! This module is designed to be used to decode incoming Sv2 messages, with optional Noise
//! protocol encryption support for secure communication.
//!
//! ## Example
//!
Expand Down
44 changes: 44 additions & 0 deletions protocols/v2/codec-sv2/src/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
//! # Stratum V2 Codec Encoder
//!
//! This module provides functionality for encoding Stratum V2 messages, including support for the
//! Noise protocol for secure communication.
//!
//! ## Features
//!
//! Two primary encoders are defined:
//! * **Standard Encoder**:
//! * **Noise Encoder**:
//!
//! ## Types
//!
//! * `Encoder`: Encoder for Sv2 frames with Noise protocol support.
//! * `NoiseEncoder`: Encoder for Sv2 frames without Noise protocol support (requires the
//! `noise_sv2` feature).
//! * `Item<T>`: Represents an SV2 frame that is to be encoded and optionally encrypted using the
//! Noise protocol.
//! * `Buffer`: Holds intermediate data during encoding, which can be either a pool-allocated
//! buffer or a system memory buffer depending on the feature flags.
//! * `Slice`: Stores the serialized SV2 frame data before transmission.
//!
//! ## Usage
//!
//! This module is designed to be used to encode outgoing Sv2 messages, with optional Noise
//! protocol encryption support for secure communication.
//!
//! ## Example
//!
//! ```ignore
//! use codec_sv2::encoder::{Encoder, NoiseEncoder};
//! use framing_sv2::framing::Sv2Frame;
//!
//! // Create a standard encoder for unencrypted SV2 frames
//! let mut encoder: Encoder<MyFrameType> = Encoder::new();
//!
//! // Encode a frame into a byte slice
//! let frame = Sv2Frame::new( /* frame details */ );
//! let encoded_data = encoder.encode(frame).unwrap();
//!
//! // Create a Noise encoder for encrypted SV2 frames (requires the `noise_sv2` feature)
//! #[cfg(feature = "noise_sv2")]
//! let mut noise_encoder: NoiseEncoder<MyFrameType> = NoiseEncoder::new();
//! ```
use alloc::vec::Vec;
use binary_sv2::{GetSize, Serialize};
#[allow(unused_imports)]
Expand Down

0 comments on commit 25e159d

Please sign in to comment.