Trait zvariant::Type

source ·
pub trait Type {
    // Required method
    fn signature() -> Signature<'static>;
}
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.

Required Methods§

source

fn signature() -> Signature<'static>

Get the signature for the implementing type.

Example
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}");

Implementations on Foreign Types§

source§

impl Type for i16

source§

fn signature() -> Signature<'static>

source§

impl<T> Type for Option<T>where T: Type,

source§

fn signature() -> Signature<'static>

source§

impl Type for IpAddr

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for Duration

source§

fn signature() -> Signature<'static>

source§

impl<T0, T1, T2, T3, T4> Type for (T0, T1, T2, T3, T4)where T0: Type, T1: Type, T2: Type, T3: Type, T4: Type,

source§

fn signature() -> Signature<'static>

source§

impl Type for Date

source§

fn signature() -> Signature<'static>

source§

impl Type for Month

source§

fn signature() -> Signature<'static>

source§

impl Type for str

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for u32

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for Mutex<T>

source§

fn signature() -> Signature<'static>

source§

impl Type for Weekday

source§

fn signature() -> Signature<'static>

source§

impl Type for Path

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for Url

source§

fn signature() -> Signature<'static>

source§

impl Type for ()

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for Bytes

source§

fn signature() -> Signature<'static>

source§

impl Type for PathBuf

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for OffsetDateTime

source§

fn signature() -> Signature<'static>

source§

impl Type for UtcOffset

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for Box<T>

source§

fn signature() -> Signature<'static>

source§

impl Type for u8

source§

fn signature() -> Signature<'static>

source§

impl<Tz: TimeZone> Type for DateTime<Tz>

source§

fn signature() -> Signature<'static>

source§

impl Type for char

source§

fn signature() -> Signature<'static>

source§

impl<T> Type for [T]where T: Type,

source§

fn signature() -> Signature<'static>

source§

impl Type for f64

source§

fn signature() -> Signature<'static>

source§

impl Type for f32

source§

fn signature() -> Signature<'static>

source§

impl Type for NaiveTime

source§

fn signature() -> Signature<'static>

source§

impl Type for i64

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for Arc<T>

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for Rc<T>

source§

fn signature() -> Signature<'static>

source§

impl Type for Time

source§

fn signature() -> Signature<'static>

source§

impl<const CAP: usize> Type for ArrayString<CAP>

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for i32

source§

fn signature() -> Signature<'static>

source§

impl Type for Uuid

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for RwLock<T>

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for &mut T

source§

fn signature() -> Signature<'static>

source§

impl<T0> Type for (T0,)where T0: Type,

source§

fn signature() -> Signature<'static>

source§

impl<T0, T1> Type for (T0, T1)where T0: Type, T1: Type,

source§

fn signature() -> Signature<'static>

source§

impl<K, V, H> Type for HashMap<K, V, H>where K: Type + Eq + Hash, V: Type, H: BuildHasher,

source§

fn signature() -> Signature<'static>

source§

impl<T, const N: usize> Type for [T; N]where T: Type,

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for PrimitiveDateTime

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for Ipv6Addr

source§

fn signature() -> Signature<'static>

source§

impl<T0, T1, T2> Type for (T0, T1, T2)where T0: Type, T1: Type, T2: Type,

source§

fn signature() -> Signature<'static>

source§

impl Type for u64

source§

fn signature() -> Signature<'static>

source§

impl Type for Ipv4Addr

source§

fn signature() -> Signature<'static>

source§

impl<F> Type for BitFlags<F>where F: Type + BitFlag,

source§

fn signature() -> Signature<'static>

source§

impl<T0, T1, T2, T3> Type for (T0, T1, T2, T3)where T0: Type, T1: Type, T2: Type, T3: Type,

source§

fn signature() -> Signature<'static>

source§

impl<K, V> Type for BTreeMap<K, V>where K: Type + Ord, V: Type,

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl Type for i8

source§

fn signature() -> Signature<'static>

source§

impl Type for ByteBuf

source§

fn signature() -> Signature<'static>

source§

impl Type for SystemTime

source§

fn signature() -> Signature<'static>

source§

impl<T> Type for Vec<T>where T: Type,

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type + ToOwned> Type for Cow<'_, T>

source§

fn signature() -> Signature<'static>

source§

impl Type for u16

source§

fn signature() -> Signature<'static>

source§

impl Type for bool

source§

fn signature() -> Signature<'static>

source§

impl Type for NaiveDateTime

source§

fn signature() -> Signature<'static>

source§

impl<T, const CAP: usize> Type for ArrayVec<T, CAP>where T: Type,

source§

fn signature() -> Signature<'static>

source§

impl<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,

source§

fn signature() -> Signature<'static>

source§

impl<T> Type for PhantomData<T>where T: Type + ?Sized,

source§

fn signature() -> Signature<'static>

source§

impl<T: ?Sized + Type> Type for &T

source§

fn signature() -> Signature<'static>

source§

impl Type for String

source§

fn signature() -> Signature<'static>

Implementors§

source§

impl Type for OwnedObjectPath

source§

impl Type for OwnedSignature

source§

impl Type for OwnedValue

source§

impl<'a> Type for Value<'a>

source§

impl<'a> Type for ObjectPath<'a>

source§

impl<'a> Type for Signature<'a>

source§

impl<'a> Type for Str<'a>

source§

impl<'a, T: Type + Serialize> Type for SerializeValue<'a, T>

source§

impl<'de, T: Type + Deserialize<'de>> Type for DeserializeValue<'de, T>

source§

impl<T> Type for Optional<T>where T: Type,