Skip to main content

Crate wire

Crate wire 

Source
Expand description

Wire framing and packet layout for the sdec codec.

This crate handles the binary wire format: packet headers, section framing, and limit enforcement. It does not know about game state types—only the structure of packets.

§Design Principles

  • Stable wire format - The format is versioned and changes are documented.
  • Bounded decoding - All length fields are validated against limits before iteration.
  • No domain knowledge - This crate handles framing, not game logic.

See WIRE_FORMAT.md for the complete specification.

Structs§

Limits
Wire-level limits for packet decoding.
PacketFlags
Packet flags.
PacketHeader
Packet header (version 0).
SessionFlags
Flags for session headers (compact, 1 byte).
SessionHeader
Decoded session header (compact format).
WirePacket
A decoded wire packet.
WireSection
A section within a wire packet.

Enums§

DecodeError
High-level decode errors for wire framing.
EncodeError
Errors that can occur during encoding.
LimitKind
Specific wire limits that can be exceeded.
SectionFramingError
Errors that can occur while framing sections.
SectionTag
Section tags for version 2.

Constants§

HEADER_SIZE
Header size in bytes (28 total).
MAGIC
Magic number identifying sdec packets.
SESSION_MAX_HEADER_SIZE
Maximum encoded size of a session header in bytes.
VERSION
Current wire format version.

Functions§

decode_packet
Decodes a wire packet into header + section slices.
decode_sections
Decodes sections from a payload buffer (no packet header).
decode_session_header
Decodes a compact session header from the provided buffer.
encode_header
Encodes a packet header into the provided output buffer.
encode_section
Encodes a single section into the provided output buffer.
encode_session_header
Encodes a compact session header into the provided buffer.

Type Aliases§

WireResult
Result type for wire format operations.