Struct poster::ContextHandle

source ·
pub struct ContextHandle { /* private fields */ }
Expand description

Cloneable handle to the client Context. The ContextHandle object is used to perform MQTT operations.

Implementations§

source§

impl ContextHandle

source

pub async fn disconnect<'a>( &mut self, opts: DisconnectOpts<'a> ) -> Result<(), MqttError>

Performs graceful disconnection with the broker by sending the Disconnect packet.

source

pub async fn ping(&mut self) -> Result<(), MqttError>

Sends ping to the broker by sending Ping packet. This method MUST be called periodically if session_expiry_interval was set during connection request in order to maintain the session.

source

pub async fn publish<'a>( &mut self, opts: PublishOpts<'a> ) -> Result<(), MqttError>

Publish data with the parameters set in PublishOpts. Acknowledgement of QoS>0 messages is handled automatically.

Errors
source

pub async fn subscribe<'a>( &mut self, opts: SubscribeOpts<'a> ) -> Result<SubscribeRsp, MqttError>

Performs subscription to the topics specified in opts. This corresponds to sending the Subscribe packet.

QoS>0 messages are acknowledged automatically.

On success returns SubscribeRsp object containing the acknowledgment data from the broker. This object can be transformed into the asynchronous stream of messages published to the subscribed topics by using the stream method.

Errors

Per-topic reason codes are retrieved with the payload method.

source

pub async fn unsubscribe<'a>( &mut self, opts: UnsubscribeOpts<'a> ) -> Result<UnsubscribeRsp, MqttError>

Unsubscribes from the topics specified in opts. This corresponds to sending the Unsubscribe packet.

Errors

Per-topic reason codes are retrieved with the payload method.

Trait Implementations§

source§

impl Clone for ContextHandle

source§

fn clone(&self) -> ContextHandle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.