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.
- Packet
Flags - Packet flags.
- Packet
Header - Packet header (version 0).
- Session
Flags - Flags for session headers (compact, 1 byte).
- Session
Header - Decoded session header (compact format).
- Wire
Packet - A decoded wire packet.
- Wire
Section - A section within a wire packet.
Enums§
- Decode
Error - High-level decode errors for wire framing.
- Encode
Error - Errors that can occur during encoding.
- Limit
Kind - Specific wire limits that can be exceeded.
- Section
Framing Error - Errors that can occur while framing sections.
- Section
Tag - 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§
- Wire
Result - Result type for wire format operations.