Expand description
Trait implemented by all serializable types.
This very simple trait provides the signature for the implementing type. Since the D-Bus type
system relies on these signatures, our serialization and deserialization API requires this
trait in addition to Serialize
and Deserialize
, respectively.
Implementation is provided for all the basic types and blanket implementations for common
container types, such as, arrays, slices, tuples, Vec
and HashMap
. For easy
implementation for custom types, use Type
derive macro from zvariant_derive crate.
If your type’s signature cannot be determined statically, you should implement the
DynamicType trait instead, which is otherwise automatically implemented if you implement this
trait.
Get the signature for the implementing type.
use std::collections::HashMap;
use zvariant::Type;
assert_eq!(u32::signature(), "u");
assert_eq!(String::signature(), "s");
assert_eq!(<(u32, &str, u64)>::signature(), "(ust)");
assert_eq!(<(u32, &str, &[u64])>::signature(), "(usat)");
assert_eq!(<HashMap<u8, &str>>::signature(), "a{ys}");
sourceimpl<T0, T1, T2, T3> Type for (T0, T1, T2, T3) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
sourceimpl<T0, T1, T2, T3, T4> Type for (T0, T1, T2, T3, T4) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
sourceimpl<T0, T1, T2, T3, T4, T5> Type for (T0, T1, T2, T3, T4, T5) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6> Type for (T0, T1, T2, T3, T4, T5, T6) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7> Type for (T0, T1, T2, T3, T4, T5, T6, T7) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
T11: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
T11: Type,
T12: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
T11: Type,
T12: Type,
T13: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
T11: Type,
T12: Type,
T13: Type,
T14: Type,
sourceimpl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) where
T0: Type,
T1: Type,
T2: Type,
T3: Type,
T4: Type,
T5: Type,
T6: Type,
T7: Type,
T8: Type,
T9: Type,
T10: Type,
T11: Type,
T12: Type,
T13: Type,
T14: Type,
T15: Type,