Struct rustbus::message_builder::MessageBodyParser [−][src]
pub struct MessageBodyParser<'body> { /* fields omitted */ }
Iterate over the messages parameters
Because dbus allows for multiple toplevel params without an enclosing struct, this provides a simple Iterator (sadly not std::iterator::Iterator, since the types
of the parameters can be different)
that you can use to get the params one by one, calling get::<T>
until you have obtained all the parameters.
If you try to get more parameters than the signature has types, it will return None, if you try to get a parameter that doesn not
fit the current one, it will return an Error::WrongSignature, but you can safely try other types, the iterator stays valid.
Implementations
impl<'ret, 'fds, 'body: 'ret + 'fds> MessageBodyParser<'body>
[src]
impl<'ret, 'fds, 'body: 'ret + 'fds> MessageBodyParser<'body>
[src]pub fn new(body: &'body MarshalledMessageBody) -> Self
[src]
pub fn get_next_sig(&self) -> Option<&Type>
[src]
Get the next params signature (if any are left)
pub fn get_left_sigs(&self) -> Option<&[Type]>
[src]
Get the remaining params signature (if any are left)
pub fn get<T: Unmarshal<'body, 'fds>>(&mut self) -> Result<T, Error>
[src]
Get the next param, use get::let s = parser.get::<String>()?;
This checks if there are params left in the message and if the type you requested fits the signature of the message.
pub fn get2<T1, T2>(&mut self) -> Result<(T1, T2), Error> where
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
[src]
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
Get the next two params, use get2::<TYPE, TYPE> to specify what type you expect. For example let s = parser.get2::<String, i32>()?;
This checks if there are params left in the message and if the type you requested fits the signature of the message.
pub fn get3<T1, T2, T3>(&mut self) -> Result<(T1, T2, T3), Error> where
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
[src]
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
Get the next three params, use get3::<TYPE, TYPE, TYPE> to specify what type you expect. For example let s = parser.get3::<String, i32, u64>()?;
This checks if there are params left in the message and if the type you requested fits the signature of the message.
pub fn get4<T1, T2, T3, T4>(&mut self) -> Result<(T1, T2, T3, T4), Error> where
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
T4: Unmarshal<'body, 'fds>,
[src]
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
T4: Unmarshal<'body, 'fds>,
Get the next four params, use get4::<TYPE, TYPE, TYPE, TYPE> to specify what type you expect. For example let s = parser.get4::<String, i32, u64, u8>()?;
This checks if there are params left in the message and if the type you requested fits the signature of the message.
pub fn get5<T1, T2, T3, T4, T5>(
&mut self
) -> Result<(T1, T2, T3, T4, T5), Error> where
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
T4: Unmarshal<'body, 'fds>,
T5: Unmarshal<'body, 'fds>,
[src]
&mut self
) -> Result<(T1, T2, T3, T4, T5), Error> where
T1: Unmarshal<'body, 'fds>,
T2: Unmarshal<'body, 'fds>,
T3: Unmarshal<'body, 'fds>,
T4: Unmarshal<'body, 'fds>,
T5: Unmarshal<'body, 'fds>,
Get the next five params, use get5::<TYPE, TYPE, TYPE, TYPE, TYPE> to specify what type you expect. For example let s = parser.get4::<String, i32, u64, u8, bool>()?;
This checks if there are params left in the message and if the type you requested fits the signature of the message.
pub fn get_param(&mut self) -> Result<Param<'_, '_>, Error>
[src]
Get the next (old_style) param. This checks if there are params left in the message and if the type you requested fits the signature of the message.