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
impl ContextHandle
sourcepub async fn disconnect<'a>(
&mut self,
opts: DisconnectOpts<'a>
) -> Result<(), MqttError>
pub async fn disconnect<'a>( &mut self, opts: DisconnectOpts<'a> ) -> Result<(), MqttError>
Performs graceful disconnection with the broker by sending the Disconnect packet.
sourcepub async fn ping(&mut self) -> Result<(), MqttError>
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.
sourcepub async fn publish<'a>(
&mut self,
opts: PublishOpts<'a>
) -> Result<(), MqttError>
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
- MqttError::PubackError returned when QoS==1 is performed and the PUBACK reason vaule is greater or equal 0x80.
- MqttError::PubrecError returned when QoS==2 is performed and the PUBREC reason value is greater or equal 0x80.
- MqttError::PubcompError returned when QoS==2 is performed and the PUBCOMP reason value is greater or equal 0x80.
sourcepub async fn subscribe<'a>(
&mut self,
opts: SubscribeOpts<'a>
) -> Result<SubscribeRsp, MqttError>
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.
sourcepub async fn unsubscribe<'a>(
&mut self,
opts: UnsubscribeOpts<'a>
) -> Result<UnsubscribeRsp, MqttError>
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
impl Clone for ContextHandle
source§fn clone(&self) -> ContextHandle
fn clone(&self) -> ContextHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more