Expand description
Encoding functions for complete frames.
ⓘ
async fn example(socket: &mut TcpStream, buf: &mut BytesMut) -> Result<(), RedisProtocolError> {
// in many cases the starting buffer wont be empty, so this example shows how to track the offset as well
let frame = Frame::BlobString { data: "foobarbaz".into(), attributes: None };
let offset = encode_bytes(buf, &frame).expect("Failed to encode frame");
let _ = socket.write_all(&buf).await.expect("Failed to write to socket");
let _ = buf.split_to(offset);
Ok(())
}
Functions
Attempt to encode a frame into buf
at the provided offset
.
Attempt to encode a frame into buf
, extending the buffer as needed.