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
DecodeError::UnexpectedEofif the buffer has fewer bytes than the declared length.DecodeError::MessageTooLargeif the declared length overflowsusize.
§Panics
If buf.chunk() returns an empty slice before buf.remaining() bytes have
been read — a Buf that violates its own contract.