Struct dbus::arg::Iter[][src]

pub struct Iter<'a>(_, _, _);

Helper struct for retrieve one or more arguments from a Message.

Implementations

impl<'a> Iter<'a>[src]

pub fn new(m: &'a Message) -> Iter<'a>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = Box<dyn RefArg + 'static>;
[src]

Creates a new struct for iterating over the arguments of a message, starting with the first argument.

pub fn get<T: Get<'a>>(&mut self) -> Option<T>[src]

Returns the current argument, if T is the argument type. Otherwise returns None.

pub fn get_refarg(&mut self) -> Option<Box<dyn RefArg + 'static>>[src]

Returns the current argument as a trait object.

Note: For the more complex arguments (arrays / dicts / structs, and especially combinations thereof), their internal representations are still a bit in flux. Instead, use as_iter() to read the values of those.

The rest are unlikely to change - Variants are Variant<Box<dyn RefArg>>, strings are String, paths are Path<'static>, signatures are Signature<'static>, Int32 are i32s and so on.

pub fn signature(&mut self) -> Signature<'static>[src]

Returns the type signature for the current argument.

pub fn arg_type(&mut self) -> ArgType[src]

The raw arg_type for the current item.

Unlike Arg::arg_type, this requires access to self and is not a static method. You can match this against Arg::arg_type for different types to understand what type the current item is. In case you're past the last argument, this function will return 0.

pub fn next(&mut self) -> bool[src]

Returns false if there are no more items.

pub fn read<T: Arg + Get<'a>>(&mut self) -> Result<T, TypeMismatchError>[src]

Wrapper around get and next. Calls get, and then next if get succeeded.

Also returns a Result rather than an Option to give an error if successful.

Example

struct ServiceBrowserItemNew {
    interface: i32,
    protocol: i32,
    name: String,
    item_type: String,
    domain: String,
    flags: u32,
}

fn service_browser_item_new_msg(m: &Message) -> Result<ServiceBrowserItemNew, TypeMismatchError> {
    let mut iter = m.iter_init();
    Ok(ServiceBrowserItemNew {
        interface: iter.read()?,
        protocol: iter.read()?,
        name: iter.read()?,
        item_type: iter.read()?,
        domain: iter.read()?,
        flags: iter.read()?,
    })
}

pub fn recurse(&mut self, arg_type: ArgType) -> Option<Iter<'a>>[src]

If the current argument is a container of the specified arg_type, then a new Iter is returned which is for iterating over the contents inside the container.

Primarily for internal use (the "get" function is more ergonomic), but could be useful for recursing into containers with unknown types.

Trait Implementations

impl<'a> Clone for Iter<'a>[src]

impl<'a> Copy for Iter<'a>[src]

impl<'a> Debug for Iter<'a>[src]

impl<'a> Iterator for Iter<'a>[src]

type Item = Box<dyn RefArg + 'static>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Iter<'a>[src]

impl<'a> !Send for Iter<'a>[src]

impl<'a> !Sync for Iter<'a>[src]

impl<'a> Unpin for Iter<'a>[src]

impl<'a> UnwindSafe for Iter<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.