Struct dbus::nonblock::MsgMatch[][src]

pub struct MsgMatch(_);

A struct used to handle incoming matches

Note: Due to the lack of async destructors, please call Connection.remove_match() in order to properly stop matching (instead of just dropping this struct).

Implementations

impl MsgMatch[src]

pub fn msg_cb<F: FnMut(Message) -> bool + Send + 'static>(self, f: F) -> Self[src]

Configures the match to receive a synchronous callback with only a message parameter.

pub fn cb<R: ReadAll, F: FnMut(Message, R) -> bool + Send + 'static>(
    self,
    f: F
) -> Self
[src]

Configures the match to receive a synchronous callback with a message parameter and typed message arguments.

Example

let mr = MatchRule::new_signal("com.example.dbustest", "HelloHappened");
let incoming_signal = connection.add_match(mr).await?.cb(|_, (source,): (String,)| {
   println!("Hello from {} happened on the bus!", source);
   true
});

pub fn msg_stream(self) -> (Self, UnboundedReceiver<Message>)[src]

Configures the match to receive a stream of messages.

Note: If the receiving end is disconnected and a message is received, the message matching will end but not in a clean fashion. Call remove_match() to stop matching cleanly.

pub fn stream<R: ReadAll + Send + 'static>(
    self
) -> (Self, UnboundedReceiver<(Message, R)>)
[src]

Configures the match to receive a stream of messages, parsed and ready.

Note: If the receiving end is disconnected and a message is received, the message matching will end but not in a clean fashion. Call remove_match() to stop matching cleanly.

Example

let mr = MatchRule::new_signal("com.example.dbustest", "HelloHappened");
let (incoming_signal, stream) = conn.add_match(mr).await?.stream();
let stream = stream.for_each(|(_, (source,)): (_, (String,))| {
   println!("Hello from {} happened on the bus!", source);
   async {}
});

pub fn token(&self) -> Token[src]

The token retreived can be used in a call to remove_match to stop matching on the data.

Auto Trait Implementations

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