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.
use kevy_replicate::wire::encode_frame;
let set = kevy_resp::Argv::from(vec![b"SET".to_vec(), b"k".to_vec(), b"v".to_vec()]);
assert_eq!(encode_frame(99, &set), b"*2\r\n:99\r\n*3\r\n$3\r\nSET\r\n$1\r\nk\r\n$1\r\nv\r\n");