Struct AsyncClient

Source
pub struct AsyncClient { /* private fields */ }
Expand description

Connected OPC UA client (with asynchronous API).

To disconnect, prefer method disconnect() over simply dropping the client: disconnection involves server communication and might take a short amount of time. If the client is dropped when still connected, it will synchronously clean up after itself, thereby blocking while being dropped. In most cases, this is not the desired behavior.

See Client for more details.

Implementations§

Source§

impl AsyncClient

Source

pub fn new(endpoint_url: &str) -> Result<Self>

Creates default client connected to endpoint.

If you need more control over the initialization, use ClientBuilder instead, and turn it into Client by calling connect(), then follow this with into_async() to get the asynchronous API.

§Errors

See ClientBuilder::connect() and Client::into_async().

§Panics

See ClientBuilder::connect().

Source

pub fn state(&self) -> ClientState

Gets current channel and session state, and connect status.

Source

pub async fn disconnect(self)

Disconnects from endpoint.

This consumes the client and handles the graceful shutdown of the connection. This should be preferred over simply dropping the instance to give the server a chance to clean up and also to avoid blocking unexpectedly when the client is being dropped without calling this method.

Source

pub async fn read_value(&self, node_id: &NodeId) -> Result<DataValue<Variant>>

Reads node value.

To read other attributes, see read_attribute(), read_attributes(), and read_many_attributes().

§Errors

This fails when the node does not exist or its value attribute cannot be read.

Source

pub async fn read_attribute<T: Attribute>( &self, node_id: &NodeId, attribute: T, ) -> Result<DataValue<T::Value>>

Reads node attribute.

To read only the value attribute, you can also use read_value().

§Errors

This fails when the node does not exist or the attribute cannot be read.

Source

pub async fn read_attributes( &self, node_id: &NodeId, attribute_ids: &[AttributeId], ) -> Result<Vec<Result<DataValue<Variant>>>>

Reads several node attributes.

The size and order of the result list matches the size and order of the given attribute ID list.

To read only a single attribute, you can also use read_attribute().

§Errors

This fails only when the entire request fails. When the node does not exist or one of the attributes cannot be read, an inner Err is returned.

Source

pub async fn read_many_attributes( &self, node_attributes: &[(NodeId, AttributeId)], ) -> Result<Vec<Result<DataValue<Variant>>>>

Reads a combination of node attributes.

The size and order of the result list matches the size and order of the given node ID and attribute ID list.

To read attributes of a single node, you can also use read_attributes().

§Errors

This fails only when the entire request fails. When a node does not exist or one of the attributes cannot be read, an inner Err is returned.

Source

pub async fn write_value( &self, node_id: &NodeId, value: &DataValue, ) -> Result<()>

Writes node value.

§Errors

This fails when the node does not exist or its value attribute cannot be written.

Source

pub async fn call_method( &self, object_id: &NodeId, method_id: &NodeId, input_arguments: &[Variant], ) -> Result<Vec<Variant>>

Calls specific method node at object node.

§Errors

This fails when the object or method node does not exist, the method cannot be called, or the input arguments are unexpected.

Source

pub async fn browse( &self, browse_description: &BrowseDescription, ) -> BrowseResult

Browses specific node.

Use ua::BrowseDescription::default() to set sensible defaults to browse a specific node’s children (forward references of the HierarchicalReferences type) like this:

use open62541_sys::UA_NS0ID_SERVER_SERVERSTATUS;

let node_id = ua::NodeId::ns0(UA_NS0ID_SERVER_SERVERSTATUS);
let browse_description = ua::BrowseDescription::default().with_node_id(&node_id);
let (references, continuation_point) = client.browse(&browse_description).await?;
§Errors

This fails when the node does not exist or it cannot be browsed.

Source

pub async fn browse_many( &self, browse_descriptions: &[BrowseDescription], ) -> Result<Vec<BrowseResult>>

Browses several nodes at once.

This issues only a single request to the OPC UA server (and should be preferred over several individual requests with browse() when browsing multiple nodes).

The size and order of the result list matches the size and order of the given node ID list.

§Errors

This fails only when the entire request fails. When a node does not exist or cannot be browsed, an inner Err is returned.

Source

pub async fn browse_next( &self, continuation_points: &[ContinuationPoint], ) -> Result<Vec<BrowseResult>>

Browses continuation points for more references.

This uses continuation points returned from browse() and browse_many() whenever not all references were returned (due to client or server limits).

The size and order of the result list matches the size and order of the given continuation point list.

§Errors

This fails only when the entire request fails. When a continuation point is invalid, an inner Err is returned.

Source

pub async fn create_subscription(&self) -> Result<AsyncSubscription>

Creates new subscription.

§Errors

This fails when the client is not connected.

Trait Implementations§

Source§

impl Debug for AsyncClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for AsyncClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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