Crate codec_sv2

Crate codec_sv2 

Source
Expand description

§Stratum V2 Codec Library

codec_sv2 provides the message encoding and decoding functionality for the Stratum V2 (Sv2) protocol, handling secure communication between Sv2 roles.

This crate abstracts the complexity of message encoding/decoding with optional Noise protocol support, ensuring both regular and encrypted messages can be serialized, transmitted, and decoded consistently and reliably.

§Usage

codec-sv2 supports both standard Sv2 frames (unencrypted) and Noise-encrypted Sv2 frames to ensure secure communication. To encode messages for transmission, choose between the Encoder for standard Sv2 frames or the NoiseEncoder for encrypted frames. To decode received messages, choose between the StandardDecoder for standard Sv2 frames or StandardNoiseDecoder to decrypt Noise frames.

§Build Options

This crate can be built with the following features:

  • std: Enable usage of rust std library, enabled by default.
  • noise_sv2: Enables support for Noise protocol encryption and decryption.
  • with_buffer_pool: Enables buffer pooling for more efficient memory management.

In order to use this crate in a #![no_std] environment, use the --no-default-features to remove the std feature.

§Examples

See the examples for more information:

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

error
Error Handling and Result Types

Structs§

Encoder
Encoder for standard Sv2 frames.
NoiseEncoder
Encoder for Sv2 frames with Noise protocol encryption.

Enums§

HandshakeRole
Represents the role in the Noise handshake process, either as an initiator or a responder.
State
Represents the state of the Noise protocol codec during different phases: initialization, handshake, or transport mode, where encryption and decryption are fully operational.

Type Aliases§

StandardDecoder
Standard Sv2 decoder without Noise protocol support.
StandardEitherFrame
An encoded or decoded Sv2 frame containing either a regular or Noise-protected message.
StandardNoiseDecoder
Standard Sv2 decoder with Noise protocol support.
StandardSv2Frame
An encoded or decoded Sv2 frame.