[][src]Trait zvariant::Type

pub trait Type {
    fn signature() -> Signature<'static>;
}

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.

Please note, that API is also provided to serialize and deserialize types that do not implement this trait but then you have to provide the correct signature yourself.

Required methods

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}");
Loading content...

Implementations on Foreign Types

impl Type for u8[src]

impl Type for i8[src]

impl Type for bool[src]

impl Type for i16[src]

impl Type for u16[src]

impl Type for i32[src]

impl Type for u32[src]

impl Type for i64[src]

impl Type for u64[src]

impl Type for f32[src]

impl Type for f64[src]

impl Type for str[src]

impl Type for String[src]

impl Type for char[src]

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

impl<T> Type for Vec<T> where
    T: Type
[src]

impl Type for ()[src]

impl<'_, T: ?Sized> Type for &'_ T where
    T: Type
[src]

impl<T0> Type for (T0,) where
    T0: Type
[src]

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

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

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

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

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

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
[src]

impl<T> Type for [T; 0] where
    T: Type
[src]

impl<T> Type for [T; 1] where
    T: Type
[src]

impl<T> Type for [T; 2] where
    T: Type
[src]

impl<T> Type for [T; 3] where
    T: Type
[src]

impl<T> Type for [T; 4] where
    T: Type
[src]

impl<T> Type for [T; 5] where
    T: Type
[src]

impl<T> Type for [T; 6] where
    T: Type
[src]

impl<T> Type for [T; 7] where
    T: Type
[src]

impl<T> Type for [T; 8] where
    T: Type
[src]

impl<T> Type for [T; 9] where
    T: Type
[src]

impl<T> Type for [T; 10] where
    T: Type
[src]

impl<T> Type for [T; 11] where
    T: Type
[src]

impl<T> Type for [T; 12] where
    T: Type
[src]

impl<T> Type for [T; 13] where
    T: Type
[src]

impl<T> Type for [T; 14] where
    T: Type
[src]

impl<T> Type for [T; 15] where
    T: Type
[src]

impl<T> Type for [T; 16] where
    T: Type
[src]

impl<T> Type for [T; 17] where
    T: Type
[src]

impl<T> Type for [T; 18] where
    T: Type
[src]

impl<T> Type for [T; 19] where
    T: Type
[src]

impl<T> Type for [T; 20] where
    T: Type
[src]

impl<T> Type for [T; 21] where
    T: Type
[src]

impl<T> Type for [T; 22] where
    T: Type
[src]

impl<T> Type for [T; 23] where
    T: Type
[src]

impl<T> Type for [T; 24] where
    T: Type
[src]

impl<T> Type for [T; 25] where
    T: Type
[src]

impl<T> Type for [T; 26] where
    T: Type
[src]

impl<T> Type for [T; 27] where
    T: Type
[src]

impl<T> Type for [T; 28] where
    T: Type
[src]

impl<T> Type for [T; 29] where
    T: Type
[src]

impl<T> Type for [T; 30] where
    T: Type
[src]

impl<T> Type for [T; 31] where
    T: Type
[src]

impl<T> Type for [T; 32] where
    T: Type
[src]

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

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

Loading content...

Implementors

impl Type for Fd[src]

impl<'a> Type for Value<'a>[src]

impl<'a> Type for ObjectPath<'a>[src]

impl<'a> Type for OwnedValue[src]

impl<'a> Type for Signature<'a>[src]

impl<'a> Type for Str<'a>[src]

Loading content...