pub fn from_slice_borrowed<'input, 'facet, T>(
input: &'input [u8],
) -> Result<T, DeserializeError<MsgPackError>>where
T: Facet<'facet>,
'input: 'facet,Expand description
Deserialize a value from MsgPack bytes, allowing zero-copy borrowing.
This variant requires the input to outlive the result ('input: 'facet),
enabling zero-copy deserialization of byte slices as &[u8] or Cow<[u8]>.
Use this when you need maximum performance and can guarantee the input
buffer outlives the deserialized value. For most use cases, prefer
from_slice which doesn’t have lifetime requirements.
§Example
use facet::Facet;
use facet_msgpack::from_slice_borrowed;
#[derive(Facet, Debug, PartialEq)]
struct Message<'a> {
id: u32,
data: &'a [u8],
}
// MsgPack encoding of {"id": 1, "data": <bin8 with 3 bytes>}
let bytes = &[0x82, 0xa2, b'i', b'd', 0x01, 0xa4, b'd', b'a', b't', b'a', 0xc4, 0x03, 0xAB, 0xCD, 0xEF];
let msg: Message = from_slice_borrowed(bytes).unwrap();
assert_eq!(msg.id, 1);
assert_eq!(msg.data, &[0xAB, 0xCD, 0xEF]);