Struct MessageBodyParser

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

Source

pub fn new(body: &'body MarshalledMessageBody) -> Self

Source

pub fn get_next_sig(&self) -> Option<&Type>

Get the next params signature (if any are left)

Source

pub fn get_left_sigs(&self) -> Option<&[Type]>

Get the remaining params signature (if any are left)

Source

pub fn get<T: Unmarshal<'body, 'fds>>(&mut self) -> Result<T, Error>

Get the next param, use get:: to specify what type you expect. For example 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.

Source

pub fn get2<T1, T2>(&mut self) -> Result<(T1, T2), Error>
where 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.

Source

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>,

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.

Source

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>,

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.

Source

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>,

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.

Trait Implementations§

Source§

impl<'body> Debug for MessageBodyParser<'body>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'body> Freeze for MessageBodyParser<'body>

§

impl<'body> RefUnwindSafe for MessageBodyParser<'body>

§

impl<'body> Send for MessageBodyParser<'body>

§

impl<'body> Sync for MessageBodyParser<'body>

§

impl<'body> Unpin for MessageBodyParser<'body>

§

impl<'body> UnwindSafe for MessageBodyParser<'body>

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> 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, 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.