Struct poster::Context

source ·
pub struct Context<RxStreamT, TxStreamT> { /* private fields */ }
Expand description

Client context. Responsible for socket management and direct communication with the broker.

Implementations§

Creates a new Context instance, paired with ContextHandle.

Sets up communication primitives for the context. This is the first method to call when starting the connection with the broker.

Arguments
  • rx - Read half of the stream, must be [AsyncRead] + Unpin.
  • tx - Write half of the stream, must be [AsyncWrite] + Unpin.
Note

Calling any other member function before prior call to set_up will panic.

Performs connection with the broker on the protocol level. Calling this method corresponds to sending the Connect packet.

If authentication_method and authentication_data are set in opts, the extended authorization is performed, the result of calling this method is then AuthRsp. Otherwise, the return type is ConnectRsp.

When the reason in the CONNACK packet is greater or equal 0x80, the ConnectError is returned.

When in extended authorization mode, the authorize method is used for subsequent authorization requests.

Panics

When invoked without prior call to set_up.

Performs extended authorization between the client and the broker. It corresponds to sending the Auth packet. User may perform multiple calls of this method, as needed, until the ConnectRsp is returned, meaning the authorization is successful.

When the reason in the AUTH packet is greater or equal 0x80, the AuthError is returned.

Panics

When invoked without prior call to set_up.

Starts processing MQTT traffic, blocking (on .await) the current task until graceful disconnection or error. Successful disconnection via disconnect method or receiving a Disconnect packet with reason a code equal to 0 (success) is considered a graceful disconnection.

Panics

When invoked without prior call to set_up.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.