Skip to main content

borrow_bytes

Function borrow_bytes 

Source
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