pub struct Session {
pub subscription_state: Mutex<SubscriptionState>,
/* private fields */
}Expand description
An OPC-UA session. This session provides methods for all supported services that require an open session.
Note that not all servers may support all service requests and calling an unsupported API may cause the connection to be dropped. Your client is expected to know the capabilities of the server it is calling to avoid this.
Fields§
§subscription_state: Mutex<SubscriptionState>Reference to the subscription cache for the client.
Implementations§
Source§impl Session
impl Session
Sourcepub async fn send_with_retry<T: UARequest + Clone>(
&self,
request: T,
policy: impl RequestRetryPolicy,
) -> Result<T::Out, StatusCode>
pub async fn send_with_retry<T: UARequest + Clone>( &self, request: T, policy: impl RequestRetryPolicy, ) -> Result<T::Out, StatusCode>
Send a UARequest, retrying if the request fails. Note that this will always clone the request at least once.
Source§impl Session
impl Session
Sourcepub async fn read(
&self,
nodes_to_read: &[ReadValueId],
timestamps_to_return: TimestampsToReturn,
max_age: f64,
) -> Result<Vec<DataValue>, StatusCode>
pub async fn read( &self, nodes_to_read: &[ReadValueId], timestamps_to_return: TimestampsToReturn, max_age: f64, ) -> Result<Vec<DataValue>, StatusCode>
Reads the value of nodes by sending a ReadRequest to the server.
See OPC UA Part 4 - Services 5.10.2 for complete description of the service and error responses.
§Arguments
nodes_to_read- A list ofReadValueIdto be read by the server.timestamps_to_return- TheTimestampsToReturnfor each node, Both, Server, Source or Nonemax_age- The maximum age of value to read in milliseconds. Read the service description for details. Basically it will attempt to read a value within the age range or attempt to read a new value. If 0 the server will attempt to read a new value from the datasource. If set toi32::MAXor greater, the server shall attempt to get a cached value.
§Returns
Ok(Vec<DataValue>)- A list ofDataValuecorresponding to each read operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn history_read(
&self,
history_read_details: HistoryReadAction,
timestamps_to_return: TimestampsToReturn,
release_continuation_points: bool,
nodes_to_read: &[HistoryReadValueId],
) -> Result<Vec<HistoryReadResult>, StatusCode>
pub async fn history_read( &self, history_read_details: HistoryReadAction, timestamps_to_return: TimestampsToReturn, release_continuation_points: bool, nodes_to_read: &[HistoryReadValueId], ) -> Result<Vec<HistoryReadResult>, StatusCode>
Reads historical values or events of one or more nodes. The caller is expected to provide a HistoryReadAction enum which must be one of the following:
See OPC UA Part 4 - Services 5.10.3 for complete description of the service and error responses.
§Arguments
history_read_details- A history read operation.timestamps_to_return- Enumeration of which timestamps to return.release_continuation_points- Flag indicating whether to release the continuation point for the operation.nodes_to_read- The list ofHistoryReadValueIdof the nodes to apply the history read operation to.
§Returns
Ok(Vec<HistoryReadResult>)- A list ofHistoryReadResultresults corresponding to history read operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn write(
&self,
nodes_to_write: &[WriteValue],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn write( &self, nodes_to_write: &[WriteValue], ) -> Result<Vec<StatusCode>, StatusCode>
Writes values to nodes by sending a WriteRequest to the server. Note that some servers may reject DataValues
containing source or server timestamps.
See OPC UA Part 4 - Services 5.10.4 for complete description of the service and error responses.
§Arguments
nodes_to_write- A list ofWriteValueto be sent to the server.
§Returns
Ok(Vec<StatusCode>)- A list ofStatusCoderesults corresponding to each write operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn history_update(
&self,
history_update_details: &[HistoryUpdateAction],
) -> Result<Vec<HistoryUpdateResult>, StatusCode>
pub async fn history_update( &self, history_update_details: &[HistoryUpdateAction], ) -> Result<Vec<HistoryUpdateResult>, StatusCode>
Updates historical values. The caller is expected to provide one or more history update operations in a slice of HistoryUpdateAction enums which are one of the following:
UpdateDataDetailsUpdateStructureDataDetailsUpdateEventDetailsDeleteRawModifiedDetailsDeleteAtTimeDetailsDeleteEventDetails
See OPC UA Part 4 - Services 5.10.5 for complete description of the service and error responses.
§Arguments
history_update_details- A list of history update operations.
§Returns
Ok(Vec<HistoryUpdateResult>)- A list ofHistoryUpdateResultresults corresponding to history update operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub async fn call(
&self,
methods: Vec<CallMethodRequest>,
) -> Result<Vec<CallMethodResult>, StatusCode>
pub async fn call( &self, methods: Vec<CallMethodRequest>, ) -> Result<Vec<CallMethodResult>, StatusCode>
Calls a list of methods on the server by sending a CallRequest to the server.
See OPC UA Part 4 - Services 5.11.2 for complete description of the service and error responses.
§Arguments
methods- The method to call.
§Returns
Ok(Vec<CallMethodResult>)- ACallMethodResultfor the Method call.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn call_one(
&self,
method: impl Into<CallMethodRequest>,
) -> Result<CallMethodResult, StatusCode>
pub async fn call_one( &self, method: impl Into<CallMethodRequest>, ) -> Result<CallMethodResult, StatusCode>
Calls a single method on an object on the server by sending a CallRequest to the server.
See OPC UA Part 4 - Services 5.11.2 for complete description of the service and error responses.
§Arguments
method- The method to call. Note this function takes anything that can be turned into aCallMethodRequestwhich includes a (NodeId,NodeId,Option<Vec<Variant>>) tuple which refers to the object id, method id, and input arguments respectively.
§Returns
Ok(CallMethodResult)- ACallMethodResultfor the Method call.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn call_get_monitored_items(
&self,
subscription_id: u32,
) -> Result<(Vec<u32>, Vec<u32>), StatusCode>
pub async fn call_get_monitored_items( &self, subscription_id: u32, ) -> Result<(Vec<u32>, Vec<u32>), StatusCode>
Calls GetMonitoredItems via call_method(), putting a sane interface on the input / output.
§Arguments
subscription_id- Server allocated identifier for the subscription to return monitored items for.
§Returns
Ok((Vec<u32>, Vec<u32>))- Result for call, consisting a list of (monitored_item_id, client_handle)Err(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub async fn add_nodes(
&self,
nodes_to_add: &[AddNodesItem],
) -> Result<Vec<AddNodesResult>, StatusCode>
pub async fn add_nodes( &self, nodes_to_add: &[AddNodesItem], ) -> Result<Vec<AddNodesResult>, StatusCode>
Add nodes by sending a AddNodesRequest to the server.
See OPC UA Part 4 - Services 5.7.2 for complete description of the service and error responses.
§Arguments
nodes_to_add- A list ofAddNodesItemto be added to the server.
§Returns
Ok(Vec<AddNodesResult>)- A list ofAddNodesResultcorresponding to each add node operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn add_references(
&self,
references_to_add: &[AddReferencesItem],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn add_references( &self, references_to_add: &[AddReferencesItem], ) -> Result<Vec<StatusCode>, StatusCode>
Add references by sending a AddReferencesRequest to the server.
See OPC UA Part 4 - Services 5.7.3 for complete description of the service and error responses.
§Arguments
references_to_add- A list ofAddReferencesItemto be sent to the server.
§Returns
Ok(Vec<StatusCode>)- A list ofStatusCodecorresponding to each add reference operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn delete_nodes(
&self,
nodes_to_delete: &[DeleteNodesItem],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn delete_nodes( &self, nodes_to_delete: &[DeleteNodesItem], ) -> Result<Vec<StatusCode>, StatusCode>
Delete nodes by sending a DeleteNodesRequest to the server.
See OPC UA Part 4 - Services 5.7.4 for complete description of the service and error responses.
§Arguments
nodes_to_delete- A list ofDeleteNodesItemto be sent to the server.
§Returns
Ok(Vec<StatusCode>)- A list ofStatusCodecorresponding to each delete node operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn delete_references(
&self,
references_to_delete: &[DeleteReferencesItem],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn delete_references( &self, references_to_delete: &[DeleteReferencesItem], ) -> Result<Vec<StatusCode>, StatusCode>
Delete references by sending a DeleteReferencesRequest to the server.
See OPC UA Part 4 - Services 5.7.5 for complete description of the service and error responses.
§Arguments
nodes_to_delete- A list ofDeleteReferencesItemto be sent to the server.
§Returns
Ok(Vec<StatusCode>)- A list ofStatusCodecorresponding to each delete node operation.Err(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub async fn cancel(&self, request_handle: IntegerId) -> Result<u32, StatusCode>
pub async fn cancel(&self, request_handle: IntegerId) -> Result<u32, StatusCode>
Cancels an outstanding service request by sending a CancelRequest to the server.
See OPC UA Part 4 - Services 5.6.5 for complete description of the service and error responses.
§Arguments
request_handle- Handle to the outstanding request to be cancelled.
§Returns
Ok(u32)- Success, number of cancelled requestsErr(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub fn subscription_state(&self) -> &Mutex<SubscriptionState>
pub fn subscription_state(&self) -> &Mutex<SubscriptionState>
Get the internal state of subscriptions registered on the session.
Sourcepub fn trigger_publish_now(&self)
pub fn trigger_publish_now(&self)
Trigger a publish to fire immediately.
Sourcepub async fn create_subscription(
&self,
publishing_interval: Duration,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
publishing_enabled: bool,
callback: impl OnSubscriptionNotificationCore + 'static,
) -> Result<u32, StatusCode>
pub async fn create_subscription( &self, publishing_interval: Duration, lifetime_count: u32, max_keep_alive_count: u32, max_notifications_per_publish: u32, priority: u8, publishing_enabled: bool, callback: impl OnSubscriptionNotificationCore + 'static, ) -> Result<u32, StatusCode>
Create a subscription by sending a CreateSubscriptionRequest to the server.
See OPC UA Part 4 - Services 5.13.2 for complete description of the service and error responses.
§Arguments
publishing_interval- The requested publishing interval defines the cyclic rate that the Subscription is being requested to return Notifications to the Client. This interval is expressed in milliseconds. This interval is represented by the publishing timer in the Subscription state table. The negotiated value for this parameter returned in the response is used as the default sampling interval for MonitoredItems assigned to this Subscription. If the requested value is 0 or negative, the server shall revise with the fastest supported publishing interval in milliseconds.lifetime_count- Requested lifetime count. The lifetime count shall be a minimum of three times the keep keep-alive count. When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription shall be deleted by the Server.max_keep_alive_count- Requested maximum keep-alive count. When the publishing timer has expired this number of times without requiring any NotificationMessage to be sent, the Subscription sends a keep-alive Message to the Client. The negotiated value for this parameter is returned in the response. If the requested value is 0, the server shall revise with the smallest supported keep-alive count.max_notifications_per_publish- The maximum number of notifications that the Client wishes to receive in a single Publish response. A value of zero indicates that there is no limit. The number of notifications per Publish is the sum of monitoredItems in the DataChangeNotification and events in the EventNotificationList.priority- Indicates the relative priority of the Subscription. When more than one Subscription needs to send Notifications, the Server should de-queue a Publish request to the Subscription with the highest priority number. For Subscriptions with equal priority the Server should de-queue Publish requests in a round-robin fashion. A Client that does not require special priority settings should set this value to zero.publishing_enabled- A boolean parameter with the following values -truepublishing is enabled for the Subscription,false, publishing is disabled for the Subscription. The value of this parameter does not affect the value of the monitoring mode Attribute of MonitoredItems.
§Returns
Ok(u32)- identifier for new subscriptionErr(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn modify_subscription(
&self,
subscription_id: u32,
publishing_interval: Duration,
lifetime_count: u32,
max_keep_alive_count: u32,
max_notifications_per_publish: u32,
priority: u8,
) -> Result<(), StatusCode>
pub async fn modify_subscription( &self, subscription_id: u32, publishing_interval: Duration, lifetime_count: u32, max_keep_alive_count: u32, max_notifications_per_publish: u32, priority: u8, ) -> Result<(), StatusCode>
Modifies a subscription by sending a ModifySubscriptionRequest to the server.
See OPC UA Part 4 - Services 5.13.3 for complete description of the service and error responses.
§Arguments
subscription_id- subscription identifier returned fromcreate_subscription.publishing_interval- The requested publishing interval defines the cyclic rate that the Subscription is being requested to return Notifications to the Client. This interval is expressed in milliseconds. This interval is represented by the publishing timer in the Subscription state table. The negotiated value for this parameter returned in the response is used as the default sampling interval for MonitoredItems assigned to this Subscription. If the requested value is 0 or negative, the server shall revise with the fastest supported publishing interval in milliseconds.lifetime_count- Requested lifetime count. The lifetime count shall be a minimum of three times the keep keep-alive count. When the publishing timer has expired this number of times without a Publish request being available to send a NotificationMessage, then the Subscription shall be deleted by the Server.max_keep_alive_count- Requested maximum keep-alive count. When the publishing timer has expired this number of times without requiring any NotificationMessage to be sent, the Subscription sends a keep-alive Message to the Client. The negotiated value for this parameter is returned in the response. If the requested value is 0, the server shall revise with the smallest supported keep-alive count.max_notifications_per_publish- The maximum number of notifications that the Client wishes to receive in a single Publish response. A value of zero indicates that there is no limit. The number of notifications per Publish is the sum of monitoredItems in the DataChangeNotification and events in the EventNotificationList.priority- Indicates the relative priority of the Subscription. When more than one Subscription needs to send Notifications, the Server should de-queue a Publish request to the Subscription with the highest priority number. For Subscriptions with equal priority the Server should de-queue Publish requests in a round-robin fashion. A Client that does not require special priority settings should set this value to zero.
§Returns
Ok(())- SuccessErr(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn set_publishing_mode(
&self,
subscription_ids: &[u32],
publishing_enabled: bool,
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn set_publishing_mode( &self, subscription_ids: &[u32], publishing_enabled: bool, ) -> Result<Vec<StatusCode>, StatusCode>
Changes the publishing mode of subscriptions by sending a SetPublishingModeRequest to the server.
See OPC UA Part 4 - Services 5.13.4 for complete description of the service and error responses.
§Arguments
subscription_ids- one or more subscription identifiers.publishing_enabled- A boolean parameter with the following values -truepublishing is enabled for the Subscriptions,false, publishing is disabled for the Subscriptions.
§Returns
Ok(Vec<StatusCode>)- Service return code for the action for each id,GoodorBadSubscriptionIdInvalidErr(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn transfer_subscriptions(
&self,
subscription_ids: &[u32],
send_initial_values: bool,
) -> Result<Vec<TransferResult>, StatusCode>
pub async fn transfer_subscriptions( &self, subscription_ids: &[u32], send_initial_values: bool, ) -> Result<Vec<TransferResult>, StatusCode>
Transfers Subscriptions and their MonitoredItems from one Session to another. For example, a Client may need to reopen a Session and then transfer its Subscriptions to that Session. It may also be used by one Client to take over a Subscription from another Client by transferring the Subscription to its Session.
Note that if you call this manually, you will need to register the
subscriptions in the subscription state (Session::subscription_state) in order to
receive notifications.
See OPC UA Part 4 - Services 5.13.7 for complete description of the service and error responses.
subscription_ids- one or more subscription identifiers.send_initial_values- A boolean parameter with the following values -truethe first publish response shall contain the current values of all monitored items in the subscription,false, the first publish response shall contain only the value changes since the last publish response was sent.
§Returns
Ok(Vec<TransferResult>)- TheTransferResultfor each transfer subscription.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn delete_subscription(
&self,
subscription_id: u32,
) -> Result<StatusCode, StatusCode>
pub async fn delete_subscription( &self, subscription_id: u32, ) -> Result<StatusCode, StatusCode>
Deletes a subscription by sending a DeleteSubscriptionsRequest to the server.
See OPC UA Part 4 - Services 5.13.8 for complete description of the service and error responses.
§Arguments
subscription_id- subscription identifier returned fromcreate_subscription.
§Returns
Ok(StatusCode)- Service return code for the delete action,GoodorBadSubscriptionIdInvalidErr(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn delete_subscriptions(
&self,
subscription_ids: &[u32],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn delete_subscriptions( &self, subscription_ids: &[u32], ) -> Result<Vec<StatusCode>, StatusCode>
Deletes subscriptions by sending a DeleteSubscriptionsRequest to the server with the list
of subscriptions to delete.
See OPC UA Part 4 - Services 5.13.8 for complete description of the service and error responses.
§Arguments
subscription_ids- List of subscription identifiers to delete.
§Returns
Ok(Vec<StatusCode>)- List of result for delete action on each id,GoodorBadSubscriptionIdInvalidThe size and order of the list matches the size and order of the input.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn create_monitored_items(
&self,
subscription_id: u32,
timestamps_to_return: TimestampsToReturn,
items_to_create: Vec<MonitoredItemCreateRequest>,
) -> Result<Vec<CreatedMonitoredItem>, StatusCode>
pub async fn create_monitored_items( &self, subscription_id: u32, timestamps_to_return: TimestampsToReturn, items_to_create: Vec<MonitoredItemCreateRequest>, ) -> Result<Vec<CreatedMonitoredItem>, StatusCode>
Creates monitored items on a subscription by sending a CreateMonitoredItemsRequest to the server.
See OPC UA Part 4 - Services 5.12.2 for complete description of the service and error responses.
§Arguments
subscription_id- The Server-assigned identifier for the Subscription that will report Notifications for this MonitoredItemtimestamps_to_return- An enumeration that specifies the timestamp Attributes to be transmitted for each MonitoredItem.items_to_create- A list ofMonitoredItemCreateRequestto be created and assigned to the specified Subscription.
§Returns
Ok(Vec<MonitoredItemCreateResult>)- A list ofMonitoredItemCreateResultcorresponding to the items to create. The size and order of the list matches the size and order of theitems_to_createrequest parameter.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn modify_monitored_items(
&self,
subscription_id: u32,
timestamps_to_return: TimestampsToReturn,
items_to_modify: &[MonitoredItemModifyRequest],
) -> Result<Vec<MonitoredItemModifyResult>, StatusCode>
pub async fn modify_monitored_items( &self, subscription_id: u32, timestamps_to_return: TimestampsToReturn, items_to_modify: &[MonitoredItemModifyRequest], ) -> Result<Vec<MonitoredItemModifyResult>, StatusCode>
Modifies monitored items on a subscription by sending a ModifyMonitoredItemsRequest to the server.
See OPC UA Part 4 - Services 5.12.3 for complete description of the service and error responses.
§Arguments
subscription_id- The Server-assigned identifier for the Subscription that will report Notifications for this MonitoredItem.timestamps_to_return- An enumeration that specifies the timestamp Attributes to be transmitted for each MonitoredItem.items_to_modify- The list ofMonitoredItemModifyRequestto modify.
§Returns
Ok(Vec<MonitoredItemModifyResult>)- A list ofMonitoredItemModifyResultcorresponding to the MonitoredItems to modify. The size and order of the list matches the size and order of theitems_to_modifyrequest parameter.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn set_monitoring_mode(
&self,
subscription_id: u32,
monitoring_mode: MonitoringMode,
monitored_item_ids: &[u32],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn set_monitoring_mode( &self, subscription_id: u32, monitoring_mode: MonitoringMode, monitored_item_ids: &[u32], ) -> Result<Vec<StatusCode>, StatusCode>
Sets the monitoring mode on one or more monitored items by sending a SetMonitoringModeRequest
to the server.
See OPC UA Part 4 - Services 5.12.4 for complete description of the service and error responses.
§Arguments
subscription_id- the subscription identifier containing the monitored items to be modified.monitoring_mode- the monitored mode to apply to the monitored itemsmonitored_item_ids- the monitored items to be modified
§Returns
Ok(Vec<StatusCode>)- Individual result for each monitored item.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn set_triggering(
&self,
subscription_id: u32,
triggering_item_id: u32,
links_to_add: &[u32],
links_to_remove: &[u32],
) -> Result<(Option<Vec<StatusCode>>, Option<Vec<StatusCode>>), StatusCode>
pub async fn set_triggering( &self, subscription_id: u32, triggering_item_id: u32, links_to_add: &[u32], links_to_remove: &[u32], ) -> Result<(Option<Vec<StatusCode>>, Option<Vec<StatusCode>>), StatusCode>
Sets a monitored item so it becomes the trigger that causes other monitored items to send
change events in the same update. Sends a SetTriggeringRequest to the server.
Note that items_to_remove is applied before items_to_add.
See OPC UA Part 4 - Services 5.12.5 for complete description of the service and error responses.
§Arguments
subscription_id- the subscription identifier containing the monitored item to be used as the trigger.monitored_item_id- the monitored item that is the trigger.links_to_add- zero or more items to be added to the monitored item’s triggering list.items_to_remove- zero or more items to be removed from the monitored item’s triggering list.
§Returns
Ok((Option<Vec<StatusCode>>, Option<Vec<StatusCode>>))- Individual result for each item added / removed for the SetTriggering call.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn delete_monitored_items(
&self,
subscription_id: u32,
items_to_delete: &[u32],
) -> Result<Vec<StatusCode>, StatusCode>
pub async fn delete_monitored_items( &self, subscription_id: u32, items_to_delete: &[u32], ) -> Result<Vec<StatusCode>, StatusCode>
Deletes monitored items from a subscription by sending a DeleteMonitoredItemsRequest to the server.
See OPC UA Part 4 - Services 5.12.6 for complete description of the service and error responses.
§Arguments
subscription_id- The Server-assigned identifier for the Subscription that will report Notifications for this MonitoredItem.items_to_delete- List of Server-assigned ids for the MonitoredItems to be deleted.
§Returns
Ok(Vec<StatusCode>)- List of StatusCodes for the MonitoredItems to delete. The size and order of the list matches the size and order of theitems_to_deleterequest parameter.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn republish(
&self,
subscription_id: u32,
sequence_number: u32,
) -> Result<NotificationMessage, StatusCode>
pub async fn republish( &self, subscription_id: u32, sequence_number: u32, ) -> Result<NotificationMessage, StatusCode>
Send a request to re-publish an unacknowledged notification message from the server.
If this succeeds, the session will automatically acknowledge the notification in the next publish request.
§Arguments
subscription_id- The Server-assigned identifier for the Subscription to republish from.sequence_number- Sequence number to re-publish.
§Returns
Ok(NotificationMessage)- Re-published notification message.Err(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub async fn browse(
&self,
nodes_to_browse: &[BrowseDescription],
max_references_per_node: u32,
view: Option<ViewDescription>,
) -> Result<Vec<BrowseResult>, StatusCode>
pub async fn browse( &self, nodes_to_browse: &[BrowseDescription], max_references_per_node: u32, view: Option<ViewDescription>, ) -> Result<Vec<BrowseResult>, StatusCode>
Discover the references to the specified nodes by sending a BrowseRequest to the server.
See OPC UA Part 4 - Services 5.8.2 for complete description of the service and error responses.
§Arguments
nodes_to_browse- A list ofBrowseDescriptiondescribing nodes to browse.
§Returns
Ok(Vec<BrowseResult>)- A listBrowseResultcorresponding to each node to browse. A browse result may contain a continuation point, for use withbrowse_next().Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn browse_next(
&self,
release_continuation_points: bool,
continuation_points: &[ByteString],
) -> Result<Vec<BrowseResult>, StatusCode>
pub async fn browse_next( &self, release_continuation_points: bool, continuation_points: &[ByteString], ) -> Result<Vec<BrowseResult>, StatusCode>
Continue to discover references to nodes by sending continuation points in a BrowseNextRequest
to the server. This function may have to be called repeatedly to process the initial query.
See OPC UA Part 4 - Services 5.8.3 for complete description of the service and error responses.
§Arguments
release_continuation_points- Flag indicating if the continuation points should be released by the servercontinuation_points- A list ofBrowseDescriptioncontinuation points
§Returns
Ok(Option<Vec<BrowseResult>)- A listBrowseResultcorresponding to each node to browse. A browse result may contain a continuation point, for use withbrowse_next().Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn translate_browse_paths_to_node_ids(
&self,
browse_paths: &[BrowsePath],
) -> Result<Vec<BrowsePathResult>, StatusCode>
pub async fn translate_browse_paths_to_node_ids( &self, browse_paths: &[BrowsePath], ) -> Result<Vec<BrowsePathResult>, StatusCode>
Translate browse paths to NodeIds by sending a TranslateBrowsePathsToNodeIdsRequest request to the Server
Each BrowsePath is constructed of a starting node and a RelativePath. The specified starting node
identifies the node from which the RelativePath is based. The RelativePath contains a sequence of
ReferenceTypes and BrowseNames.
See OPC UA Part 4 - Services 5.8.4 for complete description of the service and error responses.
§Arguments
browse_paths- A list ofBrowsePathnode + relative path for the server to look up
§Returns
Ok(Vec<BrowsePathResult>>)- List ofBrowsePathResultfor the list of browse paths. The size and order of the list matches the size and order of thebrowse_pathsparameter.Err(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn register_nodes(
&self,
nodes_to_register: &[NodeId],
) -> Result<Vec<NodeId>, StatusCode>
pub async fn register_nodes( &self, nodes_to_register: &[NodeId], ) -> Result<Vec<NodeId>, StatusCode>
Register nodes on the server by sending a RegisterNodesRequest. The purpose of this
call is server-dependent but allows a client to ask a server to create nodes which are
otherwise expensive to set up or maintain, e.g. nodes attached to hardware.
See OPC UA Part 4 - Services 5.8.5 for complete description of the service and error responses.
§Arguments
nodes_to_register- A list ofNodeIdnodes for the server to register
§Returns
Ok(Vec<NodeId>)- A list ofNodeIdcorresponding to size and order of the input. The server may return an alias for the inputNodeIdErr(StatusCode)- Request failed, Status code is the reason for failure.
Sourcepub async fn unregister_nodes(
&self,
nodes_to_unregister: &[NodeId],
) -> Result<(), StatusCode>
pub async fn unregister_nodes( &self, nodes_to_unregister: &[NodeId], ) -> Result<(), StatusCode>
Unregister nodes on the server by sending a UnregisterNodesRequest. This indicates to
the server that the client relinquishes any need for these nodes. The server will ignore
unregistered nodes.
See OPC UA Part 4 - Services 5.8.5 for complete description of the service and error responses.
§Arguments
nodes_to_unregister- A list ofNodeIdnodes for the server to unregister
§Returns
Ok(())- Request succeeded, server ignores invalid nodesErr(StatusCode)- Request failed, Status code is the reason for failure.
Source§impl Session
impl Session
Sourcepub fn session_id(&self) -> u32
pub fn session_id(&self) -> u32
The internal ID of the session, used to keep track of multiple sessions in the same program.
Sourcepub fn server_session_id(&self) -> NodeId
pub fn server_session_id(&self) -> NodeId
Get the current session ID. This is different from session_id, which is the client-side ID
to keep track of multiple sessions. This is the session ID the server uses to identify this session.
Sourcepub async fn wait_for_connection(&self) -> bool
pub async fn wait_for_connection(&self) -> bool
Convenience method to wait for a connection to the server.
You should also monitor the session event loop. If it ends, this method will never return.
Sourcepub fn disable_reconnects(&self)
pub fn disable_reconnects(&self)
Disable automatic reconnects. This will make the event loop quit the next time it disconnects for whatever reason.
Sourcepub fn enable_reconnects(&self)
pub fn enable_reconnects(&self)
Enable automatic reconnects. Automatically reconnecting is enabled by default.
Sourcepub async fn disconnect_inner(
&self,
delete_subscriptions: bool,
disable_reconnect: bool,
) -> Result<(), StatusCode>
pub async fn disconnect_inner( &self, delete_subscriptions: bool, disable_reconnect: bool, ) -> Result<(), StatusCode>
Inner method for disconnect. Session::disconnect and Session::disconnect_without_delete_subscriptions
are shortands for this with delete_subscriptions set to false and true respectively, and
disable_reconnect set to true.
Sourcepub async fn disconnect(&self) -> Result<(), StatusCode>
pub async fn disconnect(&self) -> Result<(), StatusCode>
Disconnect from the server and wait until disconnected.
This will set the should_reconnect flag to false on the session, indicating
that it should not attempt to reconnect to the server. You may clear this flag
yourself to
Sourcepub async fn disconnect_without_delete_subscriptions(
&self,
) -> Result<(), StatusCode>
pub async fn disconnect_without_delete_subscriptions( &self, ) -> Result<(), StatusCode>
Disconnect the server without deleting subscriptions, then wait until disconnected.
Sourcepub fn decoding_options(&self) -> &DecodingOptions
pub fn decoding_options(&self) -> &DecodingOptions
Get the decoding options used by the session.
Sourcepub fn channel(&self) -> &AsyncSecureChannel
pub fn channel(&self) -> &AsyncSecureChannel
Get a reference to the inner secure channel.
Sourcepub fn request_handle(&self) -> IntegerId
pub fn request_handle(&self) -> IntegerId
Get the next request handle.
Sourcepub fn encoding_context(&self) -> &RwLock<ContextOwned>
pub fn encoding_context(&self) -> &RwLock<ContextOwned>
Get a reference to the global encoding context.
Sourcepub fn endpoint_info(&self) -> &EndpointInfo
pub fn endpoint_info(&self) -> &EndpointInfo
Get the target endpoint for the session.
Sourcepub fn set_namespaces(&self, namespaces: NamespaceMap)
pub fn set_namespaces(&self, namespaces: NamespaceMap)
Set the namespace array on the session. Make sure that this namespace array contains the base namespace, or the session may behave unexpectedly.
Sourcepub fn add_type_loader(&self, type_loader: Arc<dyn TypeLoader>)
pub fn add_type_loader(&self, type_loader: Arc<dyn TypeLoader>)
Add a type loader to the encoding context. Note that there is no mechanism to ensure uniqueness, you should avoid adding the same type loader more than once, it will work, but there will be a small performance overhead.
Sourcepub fn context(&self) -> Arc<RwLock<ContextOwned>>
pub fn context(&self) -> Arc<RwLock<ContextOwned>>
Get a reference to the encoding
Sourcepub fn browser(&self) -> Browser<'_, (), DefaultRetryPolicy<'_>>
pub fn browser(&self) -> Browser<'_, (), DefaultRetryPolicy<'_>>
Create a browser, used to recursively browse the node hierarchy.
You must call handler on the returned browser and set a browse policy
before it can be used. You can, for example, use BrowseFilter
Sourcepub async fn read_namespace_array(&self) -> Result<NamespaceMap, Error>
pub async fn read_namespace_array(&self) -> Result<NamespaceMap, Error>
Return namespace array from server and store in namespace cache
Sourcepub fn get_namespace_index_from_cache(&self, url: &str) -> Option<u16>
pub fn get_namespace_index_from_cache(&self, url: &str) -> Option<u16>
Return index of supplied namespace url from cache