Skip to main content

decode_bytes

Function decode_bytes 

Source
pub fn decode_bytes(buf: &mut impl Buf) -> Result<Vec<u8>, DecodeError>
Expand description

Decode a bytes value: read a varint length prefix, then that many bytes.

See also decode_bytes_to_bytes for a Bytes-returning variant that is zero-copy when buf is itself Bytes-backed.

§Errors

§Panics

If buf.chunk() returns an empty slice before buf.remaining() bytes have been read — a Buf that violates its own contract.