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 serde::Serialize and serde::de::Deserialize, respectively.
Implementation is provided for all the basic types and blanket implementations
for common container types, such as, arrays, slices, tuples, Vec and
std::collections::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§
Sourceconst SIGNATURE: &'static Signature
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 SocketAddrV4
impl Type for SocketAddrV4
Source§impl Type for SocketAddrV6
impl Type for SocketAddrV6
Source§impl Type for AtomicBool
Available on target_has_atomic=8 only.
impl Type for AtomicBool
target_has_atomic=8 only.Source§impl Type for AtomicIsize
Available on target_has_atomic=ptr only.
impl Type for AtomicIsize
target_has_atomic=ptr only.Source§impl Type for AtomicUsize
Available on target_has_atomic=ptr only.
impl Type for AtomicUsize
target_has_atomic=ptr only.Source§impl Type for OffsetDateTime
impl Type for OffsetDateTime
Source§impl Type for PrimitiveDateTime
impl Type for PrimitiveDateTime
Source§impl<Idx: Type> Type for RangeInclusive<Idx>
impl<Idx: Type> Type for RangeInclusive<Idx>
Source§impl<T0, T1, T2> Type for (T0, T1, T2)
impl<T0, T1, T2> Type for (T0, T1, T2)
Source§impl<T0, T1, T2, T3> Type for (T0, T1, T2, T3)
impl<T0, T1, T2, T3> Type for (T0, T1, T2, T3)
Source§impl<T0, T1, T2, T3, T4> Type for (T0, T1, T2, T3, T4)
impl<T0, T1, T2, T3, T4> Type for (T0, T1, T2, T3, T4)
Source§impl<T0, T1, T2, T3, T4, T5> Type for (T0, T1, T2, T3, T4, T5)
impl<T0, T1, T2, T3, T4, T5> Type for (T0, T1, T2, T3, T4, T5)
Source§impl<T0, T1, T2, T3, T4, T5, T6> Type for (T0, T1, T2, T3, T4, T5, T6)
impl<T0, T1, T2, T3, T4, T5, T6> Type for (T0, T1, T2, T3, T4, T5, T6)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7> Type for (T0, T1, T2, T3, T4, T5, T6, T7)
impl<T0, T1, T2, T3, T4, T5, T6, T7> Type for (T0, T1, T2, T3, T4, T5, T6, T7)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Type for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Source§impl<T> Type for BinaryHeap<T>
impl<T> Type for BinaryHeap<T>
Source§impl<T> Type for PhantomData<T>
impl<T> Type for PhantomData<T>
Source§impl<T, const CAP: usize> Type for ArrayVec<T, CAP>where
T: Type,
Available on crate feature arrayvec only.
impl<T, const CAP: usize> Type for ArrayVec<T, CAP>where
T: Type,
arrayvec only.Source§impl<T, const CAP: usize> Type for Vec<T, CAP>where
T: Type,
Available on crate feature heapless only.
impl<T, const CAP: usize> Type for Vec<T, CAP>where
T: Type,
heapless only.Source§impl<T: Type> Type for Saturating<T>
impl<T: Type> Type for Saturating<T>
Source§impl<const CAP: usize> Type for ArrayString<CAP>
Available on crate feature arrayvec only.
impl<const CAP: usize> Type for ArrayString<CAP>
arrayvec only.