Function zvariant::from_slice_fds
source · pub fn from_slice_fds<'d, 'r: 'd, B, T>(
bytes: &'r [u8],
fds: Option<&[RawFd]>,
ctxt: EncodingContext<B>,
) -> Result<T>
Expand description
Deserialize T
from a given slice of bytes, containing file descriptor indices.
Please note that actual file descriptors are not part of the encoding and need to be transferred via an out-of-band platform specific mechanism. The encoding only contain the indices of the file descriptors and hence the reason, caller must pass a slice of file descriptors.
This function is not available on Windows.
§Examples
use zvariant::{to_bytes_fds, from_slice_fds};
use zvariant::{EncodingContext, Fd};
let ctxt = EncodingContext::<byteorder::LE>::new_dbus(0);
let (encoded, fds) = to_bytes_fds(ctxt, &Fd::from(42)).unwrap();
let decoded: Fd = from_slice_fds(&encoded, Some(&fds), ctxt).unwrap();
assert_eq!(decoded, Fd::from(42));