pub struct Client { /* private fields */ }Expand description
Fundamentum IoT Async Client
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(settings: ClientSettings) -> Result<Self, Error>
pub async fn new(settings: ClientSettings) -> Result<Self, Error>
Create new FundamentumIoTAsyncClient. Input argument should be the FundamentumIoTSettings. Returns a tuple where the first element is the
FundamentumIoTAsyncClient, and the second element is a new tuple with the eventloop and incoming
event sender. This tuple should be sent as an argument to the async_event_loop_listener.
§Errors
If the creation failed then the result returns an error FundamentumIoTError
Sourcepub async fn run(&self) -> Result<(), Error>
pub async fn run(&self) -> Result<(), Error>
Run the client’s background task.
This task continuously polls the underlying even loop which ensures messages are exchanged between this client and the broker.
Nothing will be exchanged until this task is run.
§Errors
Returns an error::Error if a fatal MQTT connection error occurs that cannot be retried or recovered from.
The underlying ConnectionError is considered fatal if it matches one of the following MQTT connection refusal codes:
ProtocolErrorUnsupportedProtocolVersionClientIdentifierNotValidBadUserNamePasswordNotAuthorizedBannedBadAuthenticationMethodUseAnotherServerServerMoved
In these cases, the client will terminate with an error. For all other connection errors (such as temporary network issues), the client will attempt to reconnect automatically (backoff).
Any error returned by this function indicates that the client can no longer function and requires user intervention.
Sourcepub async fn subscribe_config(&self, qos: QoS) -> Result<(), ClientError>
pub async fn subscribe_config(&self, qos: QoS) -> Result<(), ClientError>
Sourcepub async fn subscribe_portforward(&self, qos: QoS) -> Result<(), ClientError>
pub async fn subscribe_portforward(&self, qos: QoS) -> Result<(), ClientError>
Sourcepub async fn subscribe_commands(&self, qos: QoS) -> Result<(), ClientError>
pub async fn subscribe_commands(&self, qos: QoS) -> Result<(), ClientError>
Sourcepub async fn subscribe_actions(&self, qos: QoS) -> Result<(), ClientError>
pub async fn subscribe_actions(&self, qos: QoS) -> Result<(), ClientError>
Sourcepub fn get_receiver(&self) -> Receiver<Message>
pub fn get_receiver(&self) -> Receiver<Message>
Get a receiver of the incoming messages. Send this to any function that
wants to read the incoming messages from IoT Core.
Note that it is very important that your retrieve your receiver prior
to any subscribe_ of interest. Otherwise, you most likely won’t
receive messages sent to you in between this call and prior
subscriptions.
This is of particular importance for messages returned as a result to your subscription.
Sourcepub fn get_client(self) -> AsyncClient
pub fn get_client(self) -> AsyncClient
If you want to use the Rumqttc AsyncClient and EventLoop manually, this method can be used
to get the AsyncClient.
Sourcepub fn status_stream(&self) -> ClientStatusStream
pub fn status_stream(&self) -> ClientStatusStream
Monitor our client’s statuses over time.
The returned ClientStatusStream is a futures::Stream of
ClientStatus that can also provide the most recent status through
its current method.
§Returns
The streamable monitor instance.
Trait Implementations§
Source§impl Publisher for Client
impl Publisher for Client
Source§async fn publish_with<P: Publishable + Send>(
&self,
publishable: P,
options: PublishOptions,
) -> Result<(), Self::Error>
async fn publish_with<P: Publishable + Send>( &self, publishable: P, options: PublishOptions, ) -> Result<(), Self::Error>
PublishOptions overriding all
other options, including the Publishable::publish_overrides(). If no
options are provided, fallback options shall be used.