pub struct Client { /* private fields */ }
Expand description

Fundamentum IoT Async Client

Implementations§

source§

impl Client

source

pub async fn new( settings: ClientSettings ) -> Result<(Self, (EventLoop, Sender<Message>)), 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

source

pub async fn subscribe<S: Into<String> + Send>( &self, topic: S, qos: QoS ) -> Result<(), ClientError>

Subscribe to a topic

Errors

Returns ClientError if the request failed

source

pub async fn subscribe_config(&self, qos: QoS) -> Result<(), ClientError>

Subscribe to device’s config channel

Reference
  • registries/{REGISTRY_ID}/devices/{DEVICE_SN}/config
Errors

Returns ClientError if the request failed

source

pub async fn subscribe_commands(&self, qos: QoS) -> Result<(), ClientError>

Subscribe to device’s commands channel

Reference
  • registries/{REGISTRY_ID}/devices/{DEVICE_SN}/commands
Errors

Returns ClientError if the request failed

source

pub async fn publish<S, V>( &self, topic: S, qos: QoS, payload: V ) -> Result<(), ClientError>where S: Into<String> + Send, V: Into<Vec<u8>> + Send,

Publish to topic.

Errors

Returns ClientError if the request failed

source

pub async fn publish_events<V>( &self, qos: QoS, payload: V ) -> Result<(), ClientError>where V: Into<Vec<u8>> + Send,

Publish event

Reference
  • registries/{REGISTRY_ID}/devices/{DEVICE_SN}/events
Errors

Returns ClientError if the request failed

source

pub async fn publish_heartbeat( &self, qos: QoS, params: &HeartBeat ) -> Result<(), ClientError>

Publish heartbeat

Params
  • qos: mqtt’s qos
  • uptime: number of second since boot
Reference
  • registries/{REGISTRY_ID}/devices/{DEVICE_SN}/heartbeat
Errors

Returns ClientError if the request failed

Panics

This function should never panic because the string is controled by rust types

source

pub async fn publish_states( &self, qos: QoS, params: &StatesEvent ) -> Result<(), ClientError>

Publish states

Reference
  • registries/{REGISTRY_ID}/devices/{DEVICE_SN}/states
Errors

Returns ClientError if the request failed

Panics

This function should never panic because the string is controled by rust types

source

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

source

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.

source

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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more