Function zvariant::serialized_size[][src]

pub fn serialized_size<B, T: ?Sized>(
    ctxt: EncodingContext<B>,
    value: &T
) -> Result<usize> where
    B: ByteOrder,
    T: Serialize + Type

Calculate the serialized size of T.


This function will panic if the value to serialize contains file descriptors. Use serialized_size_fds if T (potentially) contains FDs.


use zvariant::{EncodingContext, serialized_size};

let ctxt = EncodingContext::<byteorder::LE>::new_dbus(0);
let len = serialized_size(ctxt, "hello world").unwrap();
assert_eq!(len, 16);

let len = serialized_size(ctxt, &("hello world!", 42_u64)).unwrap();
assert_eq!(len, 32);