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
impl AsyncClient
Sourcepub fn new(endpoint_url: &str) -> Result<Self>
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
Sourcepub fn state(&self) -> ClientState
pub fn state(&self) -> ClientState
Gets current channel and session state, and connect status.
Sourcepub async fn disconnect(self)
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.
Sourcepub async fn read_value(&self, node_id: &NodeId) -> Result<DataValue<Variant>>
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.
Sourcepub async fn read_attribute<T: Attribute>(
&self,
node_id: &NodeId,
attribute: T,
) -> Result<DataValue<T::Value>>
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.
Sourcepub async fn read_attributes(
&self,
node_id: &NodeId,
attribute_ids: &[AttributeId],
) -> Result<Vec<Result<DataValue<Variant>>>>
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.
Sourcepub async fn read_many_attributes(
&self,
node_attributes: &[(NodeId, AttributeId)],
) -> Result<Vec<Result<DataValue<Variant>>>>
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.
Sourcepub async fn write_value(
&self,
node_id: &NodeId,
value: &DataValue,
) -> Result<()>
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.
Sourcepub async fn call_method(
&self,
object_id: &NodeId,
method_id: &NodeId,
input_arguments: &[Variant],
) -> Result<Vec<Variant>>
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.
Sourcepub async fn browse(
&self,
browse_description: &BrowseDescription,
) -> BrowseResult
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.
Sourcepub async fn browse_many(
&self,
browse_descriptions: &[BrowseDescription],
) -> Result<Vec<BrowseResult>>
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.
Sourcepub async fn browse_next(
&self,
continuation_points: &[ContinuationPoint],
) -> Result<Vec<BrowseResult>>
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.