Expand description
Wire-level recording — capture every byte that crosses the transport.
RecordingCodec wraps any Codec and taps both directions of the wire:
every successful encode_setup/encode_command records the outbound bytes,
and every decode_message records the inbound bytes before decoding (so
even undecodable frames are captured). Each tap produces a WireEntry
with a monotonic sequence number, a direction, and an epoch-millis
timestamp, delivered synchronously to a WireRecorder.
Built-in recorders:
FileWireRecorder— appends JSONL to a file (base64 payloads).MemoryWireRecorder— collects entries in memory (tests, harnesses).
§Installation
The lowest-friction knob is crate::protocol::types::SessionConfig::record_wire:
connect/connect_with/ConnectBuilder all honor it by wrapping whatever
codec is in use. crate::transport::ConnectBuilder::record_wire is the
builder-level equivalent.
§Wire-log format (JSONL)
One JSON object per line; payload_b64 is the standard-base64 encoding of
the raw frame bytes:
{"seq":1,"dir":"out","ts_ms":1718000000000,"payload_b64":"eyJzZXR1cCI6eyJtb2RlbCI6Li4ufX0="}
{"seq":2,"dir":"in","ts_ms":1718000000123,"payload_b64":"eyJzZXR1cENvbXBsZXRlIjp7fX0="}Decoded, the first entry is the outbound {"setup":{...}} message and the
second the inbound {"setupComplete":{}} handshake. Logs in this format are
read back with read_wire_log and replayed with
crate::transport::replay::ReplayTransport.
Structs§
- File
Wire Recorder - Durable
WireRecorderwriting one JSON object per line (JSONL). - Memory
Wire Recorder - In-memory
WireRecorderfor tests and replay harnesses. - Recording
Codec - A
Codecdecorator that records every byte crossing the wire. - Wire
Entry - One recorded wire frame: sequence, direction, timestamp, raw payload.
- Wire
Recorder Handle - Cloneable,
Debug-friendly handle to a sharedWireRecorder.
Enums§
- Wire
Direction - Direction of a recorded wire frame, relative to the client.
- Wire
LogError - Error reading a JSONL wire log.
Traits§
- Wire
Recorder - Synchronous sink for recorded wire frames.
Functions§
- parse_
wire_ log - Parse JSONL wire-log text (one
WireEntryper non-blank line). - read_
wire_ log - Read a JSONL wire log written by
FileWireRecorderback into entries.