pub fn from_slice<'d, 'r: 'd, B, T>(
bytes: &'r [u8],
ctxt: EncodingContext<B>,
) -> Result<T>
Expand description
Deserialize T
from a given slice of bytes.
If T
is an, or (potentially) contains an Fd
, use from_slice_fds
instead.
ยงExamples
use zvariant::{to_bytes, from_slice};
use zvariant::EncodingContext;
let ctxt = EncodingContext::<byteorder::LE>::new_dbus(0);
let encoded = to_bytes(ctxt, "hello world").unwrap();
let decoded: &str = from_slice(&encoded, ctxt).unwrap();
assert_eq!(decoded, "hello world");