Skip to main content

encode_frame

Function encode_frame 

Source
pub fn encode_frame<A: ArgvView + ?Sized>(offset: u64, argv: &A) -> Vec<u8> 
Expand description

Encode one replication frame: outer *2, offset integer, then the argv as a RESP2 multi-bulk request. Allocates a fresh Vec<u8>. Generic over ArgvView so the hot path can pass a borrowed argv straight from the dispatcher (no Argv materialisation per write).

See docs/wire.md for the byte layout.

offset must fit in i64::MAX — the wire envelope uses a RESP integer for the offset, which is signed by spec. i64::MAX is 9.2 exabytes of frames; at 10M writes/s that is ~30,000 years, so no real deployment is at risk. In debug builds we assert; release builds emit a frame the peer will reject with BadOffset.