pub fn decode_bytes_to<B: ProtoBytes>(
buf: &mut impl Buf,
) -> Result<B, DecodeError>Expand description
Decode a length-delimited bytes value into a configurable ProtoBytes
type.
This is the generic counterpart to decode_bytes, dispatching to
ProtoBytes::decode_length_delimited. Its default hook hands the field’s wire payload to
ProtoBytes::from_wire. Under that default, a contiguous payload is borrowed
unless B sets ProtoBytes::PREFERS_OWNED_PAYLOAD, as Bytes does. With
the const set, the payload is an owned Bytes that shares a Bytes
input, and the value keeps that input allocated; see the const.
The declared length is checked only against the bytes left in buf. To
decode a field of a message being merged, use decode_bytes_to_ctx,
which also checks it against the end of that message.
§Errors
DecodeError::UnexpectedEofif the buffer is shorter than the declared length.DecodeError::MessageTooLargeif the declared length overflowsusize.- Any error returned by the representation’s
from_wire.