Skip to main content

Module message_codec

Module message_codec 

Source
Expand description

Length-delimited message encoding/decoding for peer communication.

Provides PeerMessageCodec which encodes messages with a 4-byte big-endian length prefix and an optional CRC32 checksum for integrity verification.

§Wire Format

+-------------------+-------------------+--------------------+
| Length (4 bytes)   | Payload (N bytes) | CRC32 (4 bytes)    |
| big-endian u32     |                   | (optional)         |
+-------------------+-------------------+--------------------+

The length prefix encodes the payload size only (not including itself or the checksum). When checksums are enabled, the CRC32 is computed over the payload bytes and appended after the payload.

Structs§

CodecConfig
Configuration for PeerMessageCodec.
CodecStats
Cumulative codec statistics.
EncodedMessage
Metadata about an encoded message.
PeerMessageCodec
Length-delimited message codec with optional CRC32 integrity checking.

Enums§

CodecError
Errors returned by PeerMessageCodec encode/decode operations.