pub struct MessageBodyParser<'body> { /* private fields */ }
Expand description
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§
Source§impl<'ret, 'fds, 'body: 'ret + 'fds> MessageBodyParser<'body>
impl<'ret, 'fds, 'body: 'ret + 'fds> MessageBodyParser<'body>
pub fn new(body: &'body MarshalledMessageBody) -> Self
Sourcepub fn get_next_sig(&self) -> Option<&Type>
pub fn get_next_sig(&self) -> Option<&Type>
Get the next params signature (if any are left)
Sourcepub fn get_left_sigs(&self) -> Option<&[Type]>
pub fn get_left_sigs(&self) -> Option<&[Type]>
Get the remaining params signature (if any are left)
Sourcepub fn get<T: Unmarshal<'body, 'fds>>(&mut self) -> Result<T, Error>
pub fn get<T: Unmarshal<'body, 'fds>>(&mut self) -> Result<T, Error>
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.
Sourcepub fn get2<T1, T2>(&mut self) -> Result<(T1, T2), Error>
pub fn get2<T1, T2>(&mut self) -> Result<(T1, T2), Error>
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.
Sourcepub fn get3<T1, T2, T3>(&mut self) -> Result<(T1, T2, T3), Error>
pub fn get3<T1, T2, T3>(&mut self) -> Result<(T1, T2, T3), Error>
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.
Sourcepub fn get4<T1, T2, T3, T4>(&mut self) -> Result<(T1, T2, T3, T4), Error>
pub fn get4<T1, T2, T3, T4>(&mut self) -> Result<(T1, T2, T3, T4), Error>
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.
Sourcepub fn get5<T1, T2, T3, T4, T5>(
&mut self,
) -> Result<(T1, T2, T3, T4, T5), Error>
pub fn get5<T1, T2, T3, T4, T5>( &mut self, ) -> Result<(T1, T2, T3, T4, T5), Error>
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.