Enum dbus::arg::messageitem::MessageItem
source · [−]pub enum MessageItem {
Show 17 variants
Array(MessageItemArray),
Struct(Vec<MessageItem>),
Variant(Box<MessageItem>),
Dict(MessageItemDict),
ObjectPath(Path<'static>),
Signature(Signature<'static>),
Str(String),
Bool(bool),
Byte(u8),
Int16(i16),
Int32(i32),
Int64(i64),
UInt16(u16),
UInt32(u32),
UInt64(u64),
Double(f64),
UnixFd(OwnedFd),
}
Expand description
MessageItem - used as parameters and return values from method calls, or as data added to a signal (old, enum version).
Note that the newer generic design (see arg
module) is both faster
and less error prone than MessageItem, and should be your first hand choice
whenever applicable.
Variants
Array(MessageItemArray)
A D-Bus array requires all elements to be of the same type. All elements must match the Signature.
Struct(Vec<MessageItem>)
A D-Bus struct allows for values of different types.
Variant(Box<MessageItem>)
A D-Bus variant is a wrapper around another MessageItem
, which
can be of any type.
Dict(MessageItemDict)
A D-Bus dictionary. All keys and values are required to be of the same type. Not all types can be dictionary keys, but all can be dictionary values.
ObjectPath(Path<'static>)
A D-Bus objectpath requires its content to be a valid objectpath, so this cannot be any string.
Signature(Signature<'static>)
A D-Bus signature requires its content to be a valid type signature, so this cannot be any string.
Str(String)
A D-Bus String is zero terminated, so no \0 s in the String, please. (D-Bus strings are also - like Rust strings - required to be valid UTF-8.)
Bool(bool)
A D-Bus boolean type.
Byte(u8)
A D-Bus unsigned 8 bit type.
Int16(i16)
A D-Bus signed 16 bit type.
Int32(i32)
A D-Bus signed 32 bit type.
Int64(i64)
A D-Bus signed 64 bit type.
UInt16(u16)
A D-Bus unsigned 16 bit type.
UInt32(u32)
A D-Bus unsigned 32 bit type.
UInt64(u64)
A D-Bus unsigned 64 bit type.
Double(f64)
A D-Bus IEEE-754 double-precision floating point type.
UnixFd(OwnedFd)
D-Bus allows for sending file descriptors, which can be used to set up SHM, unix pipes, or other communication channels.
Implementations
sourceimpl MessageItem
impl MessageItem
sourcepub fn from_dict<E, I: Iterator<Item = Result<(String, MessageItem), E>>>(
i: I
) -> Result<MessageItem, E>
pub fn from_dict<E, I: Iterator<Item = Result<(String, MessageItem), E>>>(
i: I
) -> Result<MessageItem, E>
Creates a (String, Variant) dictionary from an iterator with Result passthrough (an Err will abort and return that Err)
sourcepub fn new_array(v: Vec<MessageItem>) -> Result<MessageItem, ArrayError>
pub fn new_array(v: Vec<MessageItem>) -> Result<MessageItem, ArrayError>
Creates an MessageItem::Array from a list of MessageItems.
Note: This requires v
to be non-empty. See also
MessageItem::from(&[T])
, which can handle empty arrays as well.
sourcepub fn new_dict(
v: Vec<(MessageItem, MessageItem)>
) -> Result<MessageItem, ArrayError>
pub fn new_dict(
v: Vec<(MessageItem, MessageItem)>
) -> Result<MessageItem, ArrayError>
Creates an MessageItem::Dict from a list of MessageItem pairs.
Note: This requires v
to be non-empty. See also
MessageItem::from(&[(T1, T2)])
, which can handle empty arrays as well.
sourcepub fn inner<'a, T: TryFrom<&'a MessageItem>>(&'a self) -> Result<T, T::Error>
pub fn inner<'a, T: TryFrom<&'a MessageItem>>(&'a self) -> Result<T, T::Error>
Get the inner value of a MessageItem
Example
use dbus::arg::messageitem::MessageItem;
let m: MessageItem = 5i64.into();
let s: i64 = m.inner().unwrap();
assert_eq!(s, 5i64);
sourcepub fn peel(&self) -> &Self
pub fn peel(&self) -> &Self
Get the underlying MessageItem
of a MessageItem::Variant
Nested MessageItem::Variant
s are unwrapped recursively until a
non-Variant
is found.
Example
use dbus::arg::messageitem::MessageItem;
let nested = MessageItem::Variant(Box::new(6i64.into()));
let flat: MessageItem = 6i64.into();
assert_ne!(&nested, &flat);
assert_eq!(nested.peel(), &flat);
Trait Implementations
sourceimpl Append for MessageItem
impl Append for MessageItem
sourcefn append_by_ref(&self, i: &mut IterAppend<'_>)
fn append_by_ref(&self, i: &mut IterAppend<'_>)
sourcefn append(self, ia: &mut IterAppend<'_>)where
Self: Sized,
fn append(self, ia: &mut IterAppend<'_>)where
Self: Sized,
sourceimpl Clone for MessageItem
impl Clone for MessageItem
sourcefn clone(&self) -> MessageItem
fn clone(&self) -> MessageItem
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for MessageItem
impl Debug for MessageItem
sourceimpl<'a, T1, T2> From<&'a [(T1, T2)]> for MessageItemwhere
T1: Into<MessageItem> + Clone + Default,
T2: Into<MessageItem> + Clone + Default,
impl<'a, T1, T2> From<&'a [(T1, T2)]> for MessageItemwhere
T1: Into<MessageItem> + Clone + Default,
T2: Into<MessageItem> + Clone + Default,
Create a MessageItem::Dict
.
sourcefn from(i: &'a [(T1, T2)]) -> MessageItem
fn from(i: &'a [(T1, T2)]) -> MessageItem
sourceimpl<'a, T> From<&'a [T]> for MessageItemwhere
T: Into<MessageItem> + Clone + Default,
impl<'a, T> From<&'a [T]> for MessageItemwhere
T: Into<MessageItem> + Clone + Default,
Create a MessageItem::Array
.
sourcefn from(i: &'a [T]) -> MessageItem
fn from(i: &'a [T]) -> MessageItem
sourceimpl<'a> From<&'a str> for MessageItem
impl<'a> From<&'a str> for MessageItem
sourcefn from(i: &str) -> MessageItem
fn from(i: &str) -> MessageItem
sourceimpl From<Box<MessageItem, Global>> for MessageItem
impl From<Box<MessageItem, Global>> for MessageItem
Create a MessageItem::Variant
sourcefn from(i: Box<MessageItem>) -> MessageItem
fn from(i: Box<MessageItem>) -> MessageItem
sourceimpl From<File> for MessageItem
impl From<File> for MessageItem
sourcefn from(i: File) -> MessageItem
fn from(i: File) -> MessageItem
sourceimpl From<OwnedFd> for MessageItem
impl From<OwnedFd> for MessageItem
sourcefn from(i: OwnedFd) -> MessageItem
fn from(i: OwnedFd) -> MessageItem
sourceimpl From<Path<'static>> for MessageItem
impl From<Path<'static>> for MessageItem
sourcefn from(i: Path<'static>) -> MessageItem
fn from(i: Path<'static>) -> MessageItem
sourceimpl From<Signature<'static>> for MessageItem
impl From<Signature<'static>> for MessageItem
sourcefn from(i: Signature<'static>) -> MessageItem
fn from(i: Signature<'static>) -> MessageItem
sourceimpl From<String> for MessageItem
impl From<String> for MessageItem
sourcefn from(i: String) -> MessageItem
fn from(i: String) -> MessageItem
sourceimpl From<bool> for MessageItem
impl From<bool> for MessageItem
sourcefn from(i: bool) -> MessageItem
fn from(i: bool) -> MessageItem
sourceimpl From<f64> for MessageItem
impl From<f64> for MessageItem
sourcefn from(i: f64) -> MessageItem
fn from(i: f64) -> MessageItem
sourceimpl From<i16> for MessageItem
impl From<i16> for MessageItem
sourcefn from(i: i16) -> MessageItem
fn from(i: i16) -> MessageItem
sourceimpl From<i32> for MessageItem
impl From<i32> for MessageItem
sourcefn from(i: i32) -> MessageItem
fn from(i: i32) -> MessageItem
sourceimpl From<i64> for MessageItem
impl From<i64> for MessageItem
sourcefn from(i: i64) -> MessageItem
fn from(i: i64) -> MessageItem
sourceimpl From<u16> for MessageItem
impl From<u16> for MessageItem
sourcefn from(i: u16) -> MessageItem
fn from(i: u16) -> MessageItem
sourceimpl From<u32> for MessageItem
impl From<u32> for MessageItem
sourcefn from(i: u32) -> MessageItem
fn from(i: u32) -> MessageItem
sourceimpl From<u64> for MessageItem
impl From<u64> for MessageItem
sourcefn from(i: u64) -> MessageItem
fn from(i: u64) -> MessageItem
sourceimpl From<u8> for MessageItem
impl From<u8> for MessageItem
sourcefn from(i: u8) -> MessageItem
fn from(i: u8) -> MessageItem
sourceimpl<'a> Get<'a> for MessageItem
impl<'a> Get<'a> for MessageItem
sourceimpl PartialEq<MessageItem> for MessageItem
impl PartialEq<MessageItem> for MessageItem
sourcefn eq(&self, other: &MessageItem) -> bool
fn eq(&self, other: &MessageItem) -> bool
sourceimpl PartialOrd<MessageItem> for MessageItem
impl PartialOrd<MessageItem> for MessageItem
sourcefn partial_cmp(&self, other: &MessageItem) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageItem) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more