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:
ProtocolError
UnsupportedProtocolVersion
ClientIdentifierNotValid
BadUserNamePassword
NotAuthorized
Banned
BadAuthenticationMethod
UseAnotherServer
ServerMoved
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<S: Into<String> + Send>(
&self,
topic: S,
qos: QoS,
) -> Result<(), ClientError>
pub async fn subscribe<S: Into<String> + Send>( &self, topic: S, qos: QoS, ) -> Result<(), ClientError>
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 async fn publish<S, V>(
&self,
topic: S,
qos: QoS,
payload: V,
) -> Result<(), ClientError>
pub async fn publish<S, V>( &self, topic: S, qos: QoS, payload: V, ) -> Result<(), ClientError>
Sourcepub async fn publish_with_properties<S, V>(
&self,
topic: S,
qos: QoS,
payload: V,
publish_properties: Option<PublishProperties>,
) -> Result<(), ClientError>
pub async fn publish_with_properties<S, V>( &self, topic: S, qos: QoS, payload: V, publish_properties: Option<PublishProperties>, ) -> Result<(), ClientError>
Sourcepub async fn publish_portforward<V>(
&self,
qos: QoS,
payload: V,
headers: HashMap<String, String>,
) -> Result<(), ClientError>
pub async fn publish_portforward<V>( &self, qos: QoS, payload: V, headers: HashMap<String, String>, ) -> Result<(), ClientError>
Sourcepub async fn publish_action_response(
&self,
qos: QoS,
id: u64,
response: ActionResponse,
) -> Result<(), ClientError>
pub async fn publish_action_response( &self, qos: QoS, id: u64, response: ActionResponse, ) -> Result<(), ClientError>
Sourcepub async fn publish_events<S, V>(
&self,
sub_topic: Option<S>,
qos: QoS,
payload: V,
) -> Result<(), ClientError>
pub async fn publish_events<S, V>( &self, sub_topic: Option<S>, qos: QoS, payload: V, ) -> Result<(), ClientError>
Sourcepub async fn publish_heartbeat(
&self,
qos: QoS,
params: &HeartBeat,
) -> Result<(), ClientError>
pub async fn publish_heartbeat( &self, qos: QoS, params: &HeartBeat, ) -> Result<(), ClientError>
Sourcepub async fn publish_states(
&self,
qos: QoS,
params: &StatesEvent,
) -> Result<(), ClientError>
pub async fn publish_states( &self, qos: QoS, params: &StatesEvent, ) -> Result<(), ClientError>
Sourcepub async fn publish_update_command(
&self,
cmdid: u64,
qos: QoS,
params: &DeviceCommandUpdate,
) -> Result<(), ClientError>
pub async fn publish_update_command( &self, cmdid: u64, qos: QoS, params: &DeviceCommandUpdate, ) -> Result<(), ClientError>
Publish Device Command Update
The command update the current status of a receive command.
The device_command_id
comes from the command receive by the client.
§Reference
registries/{REGISTRY_ID}/devices/{DEVICE_SN}/commands/{DEVICE_COMMAND_ID}
§Errors
Returns ClientError
if the request failed
§Panics
This function should never panic because the string is controled by rust types
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.