Enum 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§

Source§

impl MessageItem

Source

pub fn signature(&self) -> Signature<'static>

Get the D-Bus Signature for this MessageItem.

Source

pub fn arg_type(&self) -> ArgType

Get the arg type of this MessageItem.

Source

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)

Source

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.

Source

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.

Source

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);
Source

pub fn peel(&self) -> &Self

Get the underlying MessageItem of a MessageItem::Variant

Nested MessageItem::Variants 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§

Source§

impl Append for MessageItem

Source§

fn append_by_ref(&self, i: &mut IterAppend<'_>)

Performs the append operation by borrowing self.
Source§

fn append(self, ia: &mut IterAppend<'_>)
where Self: Sized,

Performs the append operation by consuming self.
Source§

impl Clone for MessageItem

Source§

fn clone(&self) -> MessageItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T1, T2> From<&'a [(T1, T2)]> for MessageItem

Create a MessageItem::Dict.

Source§

fn from(i: &'a [(T1, T2)]) -> MessageItem

Converts to this type from the input type.
Source§

impl<'a, T> From<&'a [T]> for MessageItem
where T: Into<MessageItem> + Clone + Default,

Create a MessageItem::Array.

Source§

fn from(i: &'a [T]) -> MessageItem

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for MessageItem

Source§

fn from(i: &str) -> MessageItem

Converts to this type from the input type.
Source§

impl From<Box<MessageItem>> for MessageItem

Create a MessageItem::Variant

Source§

fn from(i: Box<MessageItem>) -> MessageItem

Converts to this type from the input type.
Source§

impl From<File> for MessageItem

Source§

fn from(i: File) -> MessageItem

Converts to this type from the input type.
Source§

impl From<OwnedFd> for MessageItem

Source§

fn from(i: OwnedFd) -> MessageItem

Converts to this type from the input type.
Source§

impl From<Path<'static>> for MessageItem

Source§

fn from(i: Path<'static>) -> MessageItem

Converts to this type from the input type.
Source§

impl From<Signature<'static>> for MessageItem

Source§

fn from(i: Signature<'static>) -> MessageItem

Converts to this type from the input type.
Source§

impl From<String> for MessageItem

Source§

fn from(i: String) -> MessageItem

Converts to this type from the input type.
Source§

impl From<bool> for MessageItem

Source§

fn from(i: bool) -> MessageItem

Converts to this type from the input type.
Source§

impl From<f64> for MessageItem

Source§

fn from(i: f64) -> MessageItem

Converts to this type from the input type.
Source§

impl From<i16> for MessageItem

Source§

fn from(i: i16) -> MessageItem

Converts to this type from the input type.
Source§

impl From<i32> for MessageItem

Source§

fn from(i: i32) -> MessageItem

Converts to this type from the input type.
Source§

impl From<i64> for MessageItem

Source§

fn from(i: i64) -> MessageItem

Converts to this type from the input type.
Source§

impl From<u16> for MessageItem

Source§

fn from(i: u16) -> MessageItem

Converts to this type from the input type.
Source§

impl From<u32> for MessageItem

Source§

fn from(i: u32) -> MessageItem

Converts to this type from the input type.
Source§

impl From<u64> for MessageItem

Source§

fn from(i: u64) -> MessageItem

Converts to this type from the input type.
Source§

impl From<u8> for MessageItem

Source§

fn from(i: u8) -> MessageItem

Converts to this type from the input type.
Source§

impl<'a> Get<'a> for MessageItem

Source§

fn get(i: &mut Iter<'a>) -> Option<Self>

Performs the get operation.
Source§

impl PartialEq for MessageItem

Source§

fn eq(&self, other: &MessageItem) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for MessageItem

Source§

fn partial_cmp(&self, other: &MessageItem) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RefArg for MessageItem

Source§

fn arg_type(&self) -> ArgType

The corresponding D-Bus argument type code.
Source§

fn signature(&self) -> Signature<'static>

The corresponding D-Bus type signature for this type.
Source§

fn append(&self, i: &mut IterAppend<'_>)

Performs the append operation.
Source§

fn as_any(&self) -> &dyn Any
where Self: 'static,

Transforms this argument to Any (which can be downcasted to read the current value). Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: 'static,

Transforms this argument to Any (which can be downcasted to read the current value). Read more
Source§

fn box_clone(&self) -> Box<dyn RefArg + 'static>

Deep clone of the RefArg, causing the result to be ’static. Read more
Source§

fn as_i64(&self) -> Option<i64>

Try to read the argument as an i64. Read more
Source§

fn as_u64(&self) -> Option<u64>

Try to read the argument as an u64. Read more
Source§

fn as_f64(&self) -> Option<f64>

Try to read the argument as an f64. Read more
Source§

fn as_str(&self) -> Option<&str>

Try to read the argument as a str. Read more
Source§

fn as_iter<'a>( &'a self, ) -> Option<Box<dyn Iterator<Item = &'a dyn RefArg> + 'a>>

Try to read the argument as an iterator. Read more
Source§

fn as_static_inner(&self, _index: usize) -> Option<&(dyn RefArg + 'static)>
where Self: 'static,

Try to read the inner of an argument, as another argument, specifying an index. Read more
Source§

fn array_clone(_arg: &[Self]) -> Option<Box<dyn RefArg + 'static>>
where Self: Sized,

Deep clone of an array. Read more
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a [(MessageItem, MessageItem)]

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a [(MessageItem, MessageItem)], ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a [MessageItem]

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a [MessageItem], ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a Box<MessageItem>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a Box<MessageItem>, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a OwnedFd

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a OwnedFd, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a Path<'static>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a Path<'static>, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a Signature<'static>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a Signature<'static>, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a String

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a String, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a Vec<MessageItem>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a Vec<MessageItem>, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for &'a str

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<&'a str, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for bool

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<bool, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for f64

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<f64, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for i16

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<i16, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for i32

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<i32, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for i64

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<i64, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for u16

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<u16, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for u32

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<u32, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for u64

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<u64, ()>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MessageItem> for u8

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(i: &'a MessageItem) -> Result<u8, ()>

Performs the conversion.
Source§

impl StructuralPartialEq for MessageItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.