1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use static_assertions::assert_impl_all;

/// The encoding format.
#[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
pub enum Format {
    /// [D-Bus](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling)
    /// format.
    #[default]
    DBus,
    /// [GVariant](https://developer.gnome.org/glib/stable/glib-GVariant.html) format.
    #[cfg(feature = "gvariant")]
    GVariant,
}

assert_impl_all!(Format: Send, Sync, Unpin);

impl std::fmt::Display for Format {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Format::DBus => write!(f, "D-Bus"),
            #[cfg(feature = "gvariant")]
            Format::GVariant => write!(f, "GVariant"),
        }
    }
}