Skip to main content

Module zmtp_framing

Module zmtp_framing 

Source
Expand description

Pure ZMTP 3.1 framing — zero I/O, zero async, wasm32-safe.

This module provides synchronous byte-manipulation functions for ZMTP 3.1 frame encoding/decoding, greeting construction/validation, and command parsing. It is compiled on all targets (including wasm32) and serves as the single source of truth for ZMTP wire format logic.

Async I/O wrappers live in transport::zmtp_quic::ZmtpStream.

Structs§

ZmtpCommand
A parsed ZMTP command.
ZmtpFrame
A parsed ZMTP frame (owned, no Bytes dependency).

Enums§

ZmqSocketType
ZMQ socket types for ZMTP handshake.

Constants§

GREETING_SIZE
ZMTP greeting size (always 64 bytes).
MAX_FRAME_SIZE
Maximum allowed frame size (64 MiB) — prevents unbounded allocation from malicious frames.
MECHANISM_NULL
ZMTP mechanism name for NULL (no encryption at ZMTP layer).
ZMTP_VERSION_MAJOR
ZMTP protocol version.
ZMTP_VERSION_MINOR

Functions§

build_greeting
Build the 64-byte ZMTP greeting.
build_ready_metadata
Build READY metadata with size-prefixed property encoding (RFC 37).
decode_flat_parts
Decode flat-encoded parts: [4B-len, data, 4B-len, data, ...]
decode_frame
Decode a single ZMTP frame from a buffer.
decode_frames_to_flat
Decode ZMTP frames to flat encoding for WASM boundary.
decode_multipart
Decode a multipart message from a buffer of concatenated ZMTP frames.
encode_command
Encode a ZMTP command frame.
encode_frame
Encode a single ZMTP frame to bytes.
encode_multipart
Encode a multipart message as ZMTP frames.
encode_multipart_flat
Encode multipart with flat encoding for WASM boundary.
validate_greeting
Validate a peer’s ZMTP greeting.
validate_ready_command
Validate a READY command.