pub struct Client<C>{ /* private fields */ }
Expand description
Azure Device Registry client implementation.
Implementations§
Source§impl<C> Client<C>
impl<C> Client<C>
Sourcepub fn new(
application_context: ApplicationContext,
client: C,
options: ClientOptions,
) -> Result<Self, Error>
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.
Sourcepub fn get_all_observed_device_endpoints(&self) -> Vec<DeviceRef>
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
Sourcepub fn get_all_observed_assets(&self) -> Vec<AssetRef>
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
Sourcepub async fn shutdown(&self) -> Result<(), Error>
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.
Sourcepub async fn get_device(
&self,
device_name: String,
inbound_endpoint_name: String,
timeout: Duration,
) -> Result<Device, Error>
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.
Sourcepub async fn get_device_status(
&self,
device_name: String,
inbound_endpoint_name: String,
timeout: Duration,
) -> Result<DeviceStatus, Error>
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.
Sourcepub async fn update_device_plus_endpoint_status(
&self,
device_name: String,
inbound_endpoint_name: String,
status: DeviceStatus,
timeout: Duration,
) -> Result<DeviceStatus, Error>
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
- ADeviceStatus
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.
Sourcepub async fn observe_device_update_notifications(
&self,
device_name: String,
inbound_endpoint_name: String,
timeout: Duration,
) -> Result<DeviceUpdateObservation, Error>
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.
Sourcepub async fn unobserve_device_update_notifications(
&self,
device_name: String,
inbound_endpoint_name: String,
timeout: Duration,
) -> Result<(), Error>
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.
Sourcepub async fn create_or_update_discovered_device(
&self,
device_name: String,
device: DiscoveredDevice,
inbound_endpoint_type: String,
timeout: Duration,
) -> Result<(String, u64), Error>
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.
Sourcepub async fn get_asset(
&self,
device_name: String,
inbound_endpoint_name: String,
asset_name: String,
timeout: Duration,
) -> Result<Asset, Error>
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.
Sourcepub async fn get_asset_status(
&self,
device_name: String,
inbound_endpoint_name: String,
asset_name: String,
timeout: Duration,
) -> Result<AssetStatus, Error>
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.
Sourcepub async fn update_asset_status(
&self,
device_name: String,
inbound_endpoint_name: String,
asset_name: String,
status: AssetStatus,
timeout: Duration,
) -> Result<AssetStatus, Error>
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
- AnAssetStatus
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.
Sourcepub async fn observe_asset_update_notifications(
&self,
device_name: String,
inbound_endpoint_name: String,
asset_name: String,
timeout: Duration,
) -> Result<AssetUpdateObservation, Error>
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.
Sourcepub async fn unobserve_asset_update_notifications(
&self,
device_name: String,
inbound_endpoint_name: String,
asset_name: String,
timeout: Duration,
) -> Result<(), Error>
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.
Sourcepub 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>
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.