pub fn borrow_bytes<'a>(buf: &mut &'a [u8]) -> Result<&'a [u8], DecodeError>Expand description
Borrow a bytes value directly from the input buffer (zero-copy).
Reads a varint length prefix, then borrows that many bytes from buf as a
&'a [u8]. The returned slice shares the lifetime 'a of the input
buffer, so no allocation is required.
ยงErrors
DecodeError::UnexpectedEofif the buffer has fewer bytes than the declared length.DecodeError::MessageTooLargeif the declared length overflowsusize.