[][src]Struct mosquitto_client_wrapper::Callbacks

pub struct Callbacks<'a, T> {
    pub data: T,
    // some fields omitted
}

Handling mosquitto callbacks. This will pass a mutable reference to the contained data to the callbacks.

Fields

data: T

Implementations

impl<'a, T> Callbacks<'a, T>[src]

pub fn new(mosq: &Mosquitto, data: T) -> Callbacks<'_, T>[src]

create a new callback handler with data. Initialize with an existing Mosquitto reference.

pub fn mosq(&self) -> &Mosquitto[src]

a reference to the Mosquitto instance

pub fn on_message<C: Fn(&mut T, MosqMessage) + 'a>(&mut self, callback: C)[src]

provide a closure which will be called when messages arrive. You are passed a mutable reference to data and the message

pub fn on_connect<C: Fn(&mut T, i32) + 'a>(&mut self, callback: C)[src]

provide a closure which is called when connection happens. You are passed a mutable reference to data and the status.

pub fn on_publish<C: Fn(&mut T, i32) + 'a>(&mut self, callback: C)[src]

provide a closure which is called after publishing a message. You are passed a mutable reference to data and the message id.

pub fn on_subscribe<C: Fn(&mut T, i32) + 'a>(&mut self, callback: C)[src]

provide a closure which is called after subscribing. You are passed a mutable reference to data and the subscription id.

pub fn on_unsubscribe<C: Fn(&mut T, i32) + 'a>(&mut self, callback: C)[src]

provide a closure which is called after unsubscribing from a topic You are passed a mutable reference to data and the subscription id.

pub fn on_disconnect<C: Fn(&mut T, i32) + 'a>(&mut self, callback: C)[src]

provide a closure which is called when client disconnects from broker. You are passed a mutable reference to data and ....

pub fn on_log<C: Fn(&mut T, u32, &str) + 'a>(&mut self, callback: C)[src]

provide a closure which is called for each log message You are passed a mutable reference to data, a logging level, and the text of the log message

Trait Implementations

impl<'a, T> Drop for Callbacks<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for Callbacks<'a, T>[src]

impl<'a, T> !Send for Callbacks<'a, T>[src]

impl<'a, T> !Sync for Callbacks<'a, T>[src]

impl<'a, T> Unpin for Callbacks<'a, T> where
    T: Unpin
[src]

impl<'a, T> !UnwindSafe for Callbacks<'a, T>[src]

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.