Module recording

Module recording 

Source
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:

§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§

FileWireRecorder
Durable WireRecorder writing one JSON object per line (JSONL).
MemoryWireRecorder
In-memory WireRecorder for tests and replay harnesses.
RecordingCodec
A Codec decorator that records every byte crossing the wire.
WireEntry
One recorded wire frame: sequence, direction, timestamp, raw payload.
WireRecorderHandle
Cloneable, Debug-friendly handle to a shared WireRecorder.

Enums§

WireDirection
Direction of a recorded wire frame, relative to the client.
WireLogError
Error reading a JSONL wire log.

Traits§

WireRecorder
Synchronous sink for recorded wire frames.

Functions§

parse_wire_log
Parse JSONL wire-log text (one WireEntry per non-blank line).
read_wire_log
Read a JSONL wire log written by FileWireRecorder back into entries.