zvariant

Trait Type

Source
pub trait Type {
    const SIGNATURE: &'static Signature;
}
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 Associated Constants§

Source

const SIGNATURE: &'static Signature

The signature for the implementing type, in parsed format.

§Example
use std::collections::HashMap;
use zvariant::{Type, signature::{Child, Signature}};

assert_eq!(u32::SIGNATURE, &Signature::U32);
assert_eq!(String::SIGNATURE, &Signature::Str);
assert_eq!(
    <(u32, &str, u64)>::SIGNATURE,
    &Signature::static_structure(&[&Signature::U32, &Signature::Str, &Signature::U64]),
);
assert_eq!(
    <(u32, &str, &[u64])>::SIGNATURE,
    &Signature::static_structure(&[
        &Signature::U32,
        &Signature::Str,
        &Signature::Array(Child::Static { child: &Signature::U64 }),
    ]),
);
assert_eq!(
    <HashMap<u8, &str>>::SIGNATURE,
    &Signature::static_dict(&Signature::U8, &Signature::Str),
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Type for IpAddr

Source§

const SIGNATURE: &'static Signature = <(u32, &[u8])>::SIGNATURE

Source§

impl Type for Month

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for Weekday

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for Month

Source§

const SIGNATURE: &'static Signature = u8::SIGNATURE

Source§

impl Type for Weekday

Source§

const SIGNATURE: &'static Signature = u8::SIGNATURE

Source§

impl Type for bool

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for char

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for f32

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for f64

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for i8

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for i16

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for i32

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for i64

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for isize

Source§

const SIGNATURE: &'static Signature = i64::SIGNATURE

Source§

impl Type for str

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for u8

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for u16

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for u32

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for u64

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for ()

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for usize

Source§

const SIGNATURE: &'static Signature = u64::SIGNATURE

Source§

impl Type for String

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for Ipv4Addr

Source§

const SIGNATURE: &'static Signature = <[u8; 4]>::SIGNATURE

Source§

impl Type for Ipv6Addr

Source§

const SIGNATURE: &'static Signature = <[u8; 16]>::SIGNATURE

Source§

impl Type for SocketAddrV4

Source§

const SIGNATURE: &'static Signature = <(Ipv4Addr, u16)>::SIGNATURE

Source§

impl Type for SocketAddrV6

Source§

const SIGNATURE: &'static Signature = <(Ipv6Addr, u16)>::SIGNATURE

Source§

impl Type for AtomicBool

Source§

const SIGNATURE: &'static Signature = <bool as Type>::SIGNATURE

Source§

impl Type for AtomicI8

Source§

const SIGNATURE: &'static Signature = <i8 as Type>::SIGNATURE

Source§

impl Type for AtomicI16

Source§

const SIGNATURE: &'static Signature = <i16 as Type>::SIGNATURE

Source§

impl Type for AtomicI32

Source§

const SIGNATURE: &'static Signature = <i32 as Type>::SIGNATURE

Source§

impl Type for AtomicI64

Source§

const SIGNATURE: &'static Signature = <i64 as Type>::SIGNATURE

Source§

impl Type for AtomicIsize

Source§

const SIGNATURE: &'static Signature = <isize as Type>::SIGNATURE

Source§

impl Type for AtomicU8

Source§

const SIGNATURE: &'static Signature = <u8 as Type>::SIGNATURE

Source§

impl Type for AtomicU16

Source§

const SIGNATURE: &'static Signature = <u16 as Type>::SIGNATURE

Source§

impl Type for AtomicU32

Source§

const SIGNATURE: &'static Signature = <u32 as Type>::SIGNATURE

Source§

impl Type for AtomicU64

Source§

const SIGNATURE: &'static Signature = <u64 as Type>::SIGNATURE

Source§

impl Type for AtomicUsize

Source§

const SIGNATURE: &'static Signature = <usize as Type>::SIGNATURE

Source§

impl Type for Duration

Source§

const SIGNATURE: &'static Signature = <(u64, u32)>::SIGNATURE

Source§

impl Type for Path

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for PathBuf

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for SystemTime

Source§

const SIGNATURE: &'static Signature = <(u64, u32)>::SIGNATURE

Source§

impl Type for Utf8Path

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for Utf8PathBuf

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NaiveDate

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for NaiveDateTime

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for NaiveTime

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for ByteBuf

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for Bytes

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for Date

Source§

const SIGNATURE: &'static Signature = <(i32, u16)>::SIGNATURE

Source§

impl Type for Duration

Source§

const SIGNATURE: &'static Signature = <(i64, i32)>::SIGNATURE

Source§

impl Type for OffsetDateTime

Source§

const SIGNATURE: &'static Signature = <(i32, u16, u8, u8, u8, u32, i8, i8, i8)>::SIGNATURE

Source§

impl Type for PrimitiveDateTime

Source§

const SIGNATURE: &'static Signature = <(i32, u16, u8, u8, u8, u32)>::SIGNATURE

Source§

impl Type for Time

Source§

const SIGNATURE: &'static Signature = <(u8, u8, u8, u32)>::SIGNATURE

Source§

impl Type for UtcOffset

Source§

const SIGNATURE: &'static Signature = <(i8, i8, i8)>::SIGNATURE

Source§

impl Type for Url

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

impl Type for Uuid

Source§

const SIGNATURE: &'static Signature = <&[u8]>::SIGNATURE

Source§

impl Type for NonZeroI8

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroI16

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroI32

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroI64

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroU8

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroU16

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroU32

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for NonZeroU64

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = F::SIGNATURE

Source§

impl<Idx: Type> Type for Range<Idx>

Source§

const SIGNATURE: &'static Signature = <(Idx, Idx)>::SIGNATURE

Source§

impl<Idx: Type> Type for RangeFrom<Idx>

Source§

const SIGNATURE: &'static Signature = <(Idx,)>::SIGNATURE

Source§

impl<Idx: Type> Type for RangeInclusive<Idx>

Source§

const SIGNATURE: &'static Signature = <(Idx, Idx)>::SIGNATURE

Source§

impl<Idx: Type> Type for RangeTo<Idx>

Source§

const SIGNATURE: &'static Signature = <(Idx,)>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

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§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

impl<T> Type for BinaryHeap<T>
where T: Type + Ord,

Source§

const SIGNATURE: &'static Signature = <[T]>::SIGNATURE

Source§

impl<T> Type for BTreeSet<T>
where T: Type + Ord,

Source§

const SIGNATURE: &'static Signature = <[T]>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

impl<T, S> Type for HashSet<T, S>
where T: Type + Eq + Hash, S: BuildHasher,

Source§

const SIGNATURE: &'static Signature = <[T]>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = <[T]>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = <[T]>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

impl<T: Type> Type for Reverse<T>

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

impl<T: Type> Type for Saturating<T>

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

impl<T: Type> Type for Wrapping<T>

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = <&str>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Implementors§

Source§

impl Type for Fd<'_>

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for Signature

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for OwnedFd

Source§

const SIGNATURE: &'static Signature = _

Source§

impl Type for OwnedObjectPath

Source§

const SIGNATURE: &'static Signature = <ObjectPath<'static> as ::zvariant::Type>::SIGNATURE

Source§

impl Type for OwnedValue

Source§

const SIGNATURE: &'static Signature = <Value<'static> as ::zvariant::Type>::SIGNATURE

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = _

Source§

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

Source§

const SIGNATURE: &'static Signature = T::SIGNATURE