pub struct Client<C>
where C: ManagedClient + Clone + Send + Sync + 'static, C::PubReceiver: Send + Sync,
{ /* private fields */ }
Expand description

Azure Device Registry client implementation.

Implementations§

Source§

impl<C> Client<C>
where C: ManagedClient + Clone + Send + Sync + 'static, C::PubReceiver: Send + Sync,

Source

pub fn new( application_context: ApplicationContext, client: C, options: ClientOptions, ) -> Result<Self, Error>

Create a new Azure Device Registry Client.

§Errors

Error of kind ValidationError if the Client Id of the ManagedClient isn’t valid as a topic token.

§Panics

Panics if the options for the underlying command invokers or receivers cannot be built. Not possible since the options are statically generated.

Source

pub fn get_all_observed_device_endpoints(&self) -> Vec<DeviceRef>

Convenience function to get all observed device & inbound endpoint names to quickly unobserve all of them before cleaning up

Source

pub fn get_all_observed_assets(&self) -> Vec<AssetRef>

Convenience function to get all observed asset names to quickly unobserve all of them before cleaning up

Source

pub async fn shutdown(&self) -> Result<(), Error>

Shutdown the Client. Shuts down the underlying command invokers.

Note: If this method is called, the Client should not be used again. If the method returns an error, it may be called again to re-attempt unsubscribing.

Returns Ok(()) on success, otherwise returns Error.

§Errors

Error of kind ShutdownError if any of the invoker unsubscribes fail or if the unsuback reason code doesn’t indicate success. This will be a vector of any shutdown errors, all invokers will attempt to be shutdown.

Source

pub async fn get_device( &self, device_name: String, inbound_endpoint_name: String, timeout: Duration, ) -> Result<Device, Error>

Retrieves a Device from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns a Device if the device was found.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn get_device_status( &self, device_name: String, inbound_endpoint_name: String, timeout: Duration, ) -> Result<DeviceStatus, Error>

Retrieves a DeviceStatus from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns the DeviceStatus if the device was found.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn update_device_plus_endpoint_status( &self, device_name: String, inbound_endpoint_name: String, status: DeviceStatus, timeout: Duration, ) -> Result<DeviceStatus, Error>

Updates a Device’s status in the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • status - A DeviceStatus containing all status information for the device.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns the updated DeviceStatus once updated.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn observe_device_update_notifications( &self, device_name: String, inbound_endpoint_name: String, timeout: Duration, ) -> Result<DeviceUpdateObservation, Error>

Starts observation of a Device’s updates from the Azure Device Registry service.

Note: On cleanup, unobserve should always be called so that the service knows to stop sending notifications.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns the DeviceUpdateObservation if the observation was started successfully or Error.

§Errors

Error of kind DuplicateObserve if the Device is already being observed.

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn unobserve_device_update_notifications( &self, device_name: String, inbound_endpoint_name: String, timeout: Duration, ) -> Result<(), Error>

Stops observation of a Device’s updates from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns Ok(()) if the device updates are no longer being observed.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn create_or_update_discovered_device( &self, device_name: String, device: DiscoveredDevice, inbound_endpoint_type: String, timeout: Duration, ) -> Result<(String, u64), Error>

Creates or updates a discovered device in the Azure Device Registry service.

If the specified discovered device does not yet exist, it will be created. If it already exists, it will be replaced.

§Arguments
  • device_name - The name of the discovered device.
  • device - The specification of the discovered device.
  • inbound_endpoint_type - The type of the inbound endpoint.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns tuple containing the discovery ID and version of the discovered device.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • inbound endpoint type is invalid for the topic.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the device name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn get_asset( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, timeout: Duration, ) -> Result<Asset, Error>

Retrieves an Asset from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the asset.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns an Asset if the the asset was found.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn get_asset_status( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, timeout: Duration, ) -> Result<AssetStatus, Error>

Retrieves an AssetStatus from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the asset.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns an AssetStatus if the the asset was found.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn update_asset_status( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, status: AssetStatus, timeout: Duration, ) -> Result<AssetStatus, Error>

Updates the status of an Asset in the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the asset.
  • status - An AssetStatus containing the status of an asset for the update.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns the updated AssetStatus once updated.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn observe_asset_update_notifications( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, timeout: Duration, ) -> Result<AssetUpdateObservation, Error>

Starts observation of an Asset’s updates from the Azure Device Registry service.

Note: On cleanup, unobserve should always be called so that the service knows to stop sending notifications.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the asset.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns an AssetUpdateObservation if the observation was started successfully or Error.

§Errors

Error of kind DuplicateObserve if the Asset is already being observed.

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn unobserve_asset_update_notifications( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, timeout: Duration, ) -> Result<(), Error>

Stops observation of an Asset’s updates from the Azure Device Registry service.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the asset.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns Ok(()) if the asset updates are no longer being observed.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Source

pub async fn create_or_update_discovered_asset( &self, device_name: String, inbound_endpoint_name: String, asset_name: String, asset: DiscoveredAsset, timeout: Duration, ) -> Result<(String, u64), Error>

Creates or updates a discovered asset in the Azure Device Registry service.

If the specified discovered asset does not yet exist, it will be created. If it already exists, it will be replaced.

§Arguments
  • device_name - The name of the device.
  • inbound_endpoint_name - The name of the inbound endpoint.
  • asset_name - The name of the discovered asset.
  • asset - The specification of the discovered asset.
  • timeout - The duration until the client stops waiting for a response to the request, it is rounded up to the nearest second.

Returns a tuple containing the discovery ID and version of the discovered asset.

§Errors

Error of kind InvalidRequestArgument if timeout is 0 or > u32::max.

Error of kind AIOProtocolError if:

  • device or inbound endpoint names are invalid.
  • there are any underlying errors from the AIO RPC protocol.

Error of kind ValidationError if the asset name is empty.

Error of kind ServiceError if an error is returned by the Azure Device Registry service.

Trait Implementations§

Source§

impl<C> Clone for Client<C>
where C: ManagedClient + Clone + Send + Sync + 'static + Clone, C::PubReceiver: Send + Sync,

Source§

fn clone(&self) -> Client<C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Client<C>

§

impl<C> !RefUnwindSafe for Client<C>

§

impl<C> Send for Client<C>

§

impl<C> Sync for Client<C>

§

impl<C> Unpin for Client<C>

§

impl<C> !UnwindSafe for Client<C>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V