Skip to main content

decode_view

Function decode_view 

Source
pub fn decode_view<'a, T: DeserializeView<'a>>(bytes: &'a [u8]) -> Result<T>
Expand description

Decode a borrowed value of type T from bytes, requiring the input to be fully consumed.

This is the Tier-1 zero-copy entry point — the symmetric counterpart to crate::decode. The decoded value borrows from bytes; the borrow checker enforces that bytes outlives the result.

§Examples

let bytes = pack_io::encode(&"hello").unwrap();
let view: &str = pack_io::decode_view(&bytes).unwrap();
assert_eq!(view, "hello");

§Errors