Struct dbus::arg::Iter
[−]
[src]
pub struct Iter<'a>(_, _);
Helper struct for retrieve one or more arguments from a Message. Note that this is not a Rust iterator, because arguments are often of different types
Methods
impl<'a> Iter<'a>
[src]
fn new(m: &'a Message) -> Iter<'a>
Creates a new struct for iterating over the arguments of a message, starting with the first argument.
fn get<T: Get<'a>>(&mut self) -> Option<T>
Returns the current argument, if T is the argument type. Otherwise returns None.
fn arg_type(&mut self) -> i32
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.
fn next(&mut self) -> bool
Returns false if there are no more items.
fn read<T: Get<'a>>(&mut self) -> Result<T, TypeMismatchError>
Wrapper around get
and next
. Calls get
, and then next
if get
succeeded.
Also returns a Result
rather than an Option
to work better with try!
.
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: try!(iter.read()), protocol: try!(iter.read()), name: try!(iter.read()), item_type: try!(iter.read()), domain: try!(iter.read()), flags: try!(iter.read()), }) }
fn recurse(&mut self, arg_type: i32) -> Option<Iter<'a>>
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.