Skip to main content

Module codec

Module codec 

Expand description

Framing helpers for turning a byte stream into Packets and back.

  • PacketReader buffers arbitrary chunks behind a ByteBuffer and yields whole packets. Parse state is stored in the reader instead of in a future. This lets an I/O driver read in one cancellation-safe step and never lose partially-read bytes.
  • PacketWriter is the outbound mirror: it encodes packets in place into a ByteBuffer for an I/O driver to drain, with no per-packet allocation.

PacketReader and PacketWriter pair with ArrayBuffer for no-alloc operation or GrowBuffer when alloc is available.

Modulesยง

buffer ๐Ÿ”’
reader ๐Ÿ”’
writer ๐Ÿ”’

Structsยง

ArrayBuffer
A fixed-capacity ByteBuffer backed by an inline [u8; N].
Frame
A complete packet at the front of a PacketReader, as found by PacketReader::peek.
GrowBufferalloc
A heap-backed ByteBuffer that grows as needed.
PacketReader
A buffering, sans-io packet framer.
PacketWriter
A buffering, sans-io packet serializer.

Enumsยง

WriteError
Error returned by PacketWriter::write.

Traitsยง

ByteBuffer
Contiguous byte storage shared by PacketReader and PacketWriter.