zvariant

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

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§

fn signature() -> Signature<'static>

Source§

impl Type for bool

Source§

fn signature() -> Signature<'static>

Source§

impl Type for char

Source§

fn signature() -> Signature<'static>

Source§

impl Type for f32

Source§

fn signature() -> Signature<'static>

Source§

impl Type for f64

Source§

fn signature() -> Signature<'static>

Source§

impl Type for i8

Source§

fn signature() -> Signature<'static>

Source§

impl Type for i16

Source§

fn signature() -> Signature<'static>

Source§

impl Type for i32

Source§

fn signature() -> Signature<'static>

Source§

impl Type for i64

Source§

fn signature() -> Signature<'static>

Source§

impl Type for str

Source§

fn signature() -> Signature<'static>

Source§

impl Type for u8

Source§

fn signature() -> Signature<'static>

Source§

impl Type for u16

Source§

fn signature() -> Signature<'static>

Source§

impl Type for u32

Source§

fn signature() -> Signature<'static>

Source§

impl Type for u64

Source§

fn signature() -> Signature<'static>

Source§

impl Type for ()

Source§

fn signature() -> Signature<'static>

Source§

impl Type for String

Source§

fn signature() -> Signature<'static>

Source§

impl Type for Ipv4Addr

Source§

fn signature() -> Signature<'static>

Source§

impl Type for Ipv6Addr

Source§

fn signature() -> Signature<'static>

Source§

impl Type for Duration

Source§

fn signature() -> Signature<'static>

Source§

impl Type for Path

Source§

fn signature() -> Signature<'static>

Source§

impl Type for PathBuf

Source§

fn signature() -> Signature<'static>

Source§

impl Type for SystemTime

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroI8

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroI16

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroI32

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroI64

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroU8

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroU16

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroU32

Source§

fn signature() -> Signature<'static>

Source§

impl Type for NonZeroU64

Source§

fn signature() -> Signature<'static>

Source§

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

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<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<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<T0, T1, T2> Type for (T0, T1, T2)
where T0: Type, T1: Type, T2: Type,

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<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<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<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<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<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<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<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<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<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, 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<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<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<T> Type for [T]
where T: Type,

Source§

fn signature() -> Signature<'static>

Source§

impl<T> Type for Vec<T>
where T: 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, S> Type for HashSet<T, S>
where T: Type + Eq + Hash, S: 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<T: ?Sized + Type + ToOwned> Type for Cow<'_, T>

Source§

fn signature() -> Signature<'static>

Source§

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

Source§

fn signature() -> Signature<'static>

Source§

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

Source§

fn signature() -> Signature<'static>

Source§

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

Source§

fn signature() -> Signature<'static>

Source§

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

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 Mutex<T>

Source§

fn signature() -> Signature<'static>

Source§

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

Source§

fn signature() -> Signature<'static>

Implementors§

Source§

impl Type for Fd

Source§

impl Type for OwnedFd

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,

impl Type for Action

impl Type for Rect

impl Type for ClipType

impl Type for CoordType

impl Type for Granularity

impl Type for Layer

impl Type for Live

impl Type for MatchType

impl Type for Role

impl Type for ScrollType

impl Type for SortOrder

impl Type for Accessible

impl Type for CacheItem

impl Type for EventBodyQT

impl Type for StateSet

impl<T> Type for EventBody<'_, T>

impl Type for EventType

impl<'a> Type for DeviceEvent<'a>

impl<'a> Type for KeyDefinition<'a>

impl<'c> Type for AccessibleProxy<'c>

impl<'c> Type for AccessibleProxyBlocking<'c>

impl<'c> Type for ActionProxy<'c>

impl<'c> Type for ActionProxyBlocking<'c>

impl<'c> Type for ApplicationProxy<'c>

impl<'c> Type for BusProxy<'c>

impl<'c> Type for BusProxyBlocking<'c>

impl<'c> Type for StatusProxy<'c>

impl<'c> Type for StatusProxyBlocking<'c>

impl<'c> Type for CacheProxy<'c>

impl<'c> Type for CacheProxyBlocking<'c>

impl<'c> Type for CollectionProxy<'c>

impl<'c> Type for CollectionProxyBlocking<'c>

impl<'c> Type for ComponentProxy<'c>

impl<'c> Type for ComponentProxyBlocking<'c>

impl<'c> Type for DocumentProxy<'c>

impl<'c> Type for DocumentProxyBlocking<'c>

impl<'c> Type for EditableTextProxy<'c>

impl<'c> Type for HyperlinkProxy<'c>

impl<'c> Type for HyperlinkProxyBlocking<'c>

impl<'c> Type for HypertextProxy<'c>

impl<'c> Type for HypertextProxyBlocking<'c>

impl<'c> Type for ImageProxy<'c>

impl<'c> Type for ImageProxyBlocking<'c>

impl<'c> Type for RegistryProxy<'c>

impl<'c> Type for RegistryProxyBlocking<'c>

impl<'c> Type for SelectionProxy<'c>

impl<'c> Type for SelectionProxyBlocking<'c>

impl<'c> Type for SocketProxy<'c>

impl<'c> Type for SocketProxyBlocking<'c>

impl<'c> Type for TableProxy<'c>

impl<'c> Type for TableProxyBlocking<'c>

impl<'c> Type for TableCellProxy<'c>

impl<'c> Type for TableCellProxyBlocking<'c>

impl<'c> Type for TextProxy<'c>

impl<'c> Type for TextProxyBlocking<'c>

impl<'c> Type for ValueProxy<'c>

impl<'c> Type for ValueProxyBlocking<'c>

impl Type for EndianSig

impl Type for MessageType

impl Type for Guid

impl<'c> Type for DBusProxy<'c>

impl<'c> Type for IntrospectableProxy<'c>

impl<'c> Type for MonitoringProxy<'c>

impl<'c> Type for ObjectManagerProxy<'c>

impl<'c> Type for PeerProxy<'c>

impl<'c> Type for PropertiesProxy<'c>

impl<'c> Type for StatsProxy<'c>

impl<'c> Type for DBusProxy<'c>

impl<'c> Type for IntrospectableProxy<'c>

impl<'c> Type for MonitoringProxy<'c>

impl<'c> Type for ObjectManagerProxy<'c>

impl<'c> Type for PeerProxy<'c>

impl<'c> Type for PropertiesProxy<'c>

impl<'c> Type for StatsProxy<'c>

impl<'f> Type for MessageField<'f>

impl<'m> Type for MatchRule<'m>

impl<'m> Type for MessageFields<'m>

impl<'m> Type for MessageHeader<'m>

impl<R> Type for ResponseDispatchNotifier<R>
where R: Type,

impl Type for BusName<'_>

impl<'name> Type for ErrorName<'name>

impl<'name> Type for InterfaceName<'name>

impl<'name> Type for MemberName<'name>

impl<'name> Type for UniqueName<'name>

impl<'name> Type for WellKnownName<'name>