Struct Session

Source
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

Source

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

Source

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 of ReadValueId to be read by the server.
  • timestamps_to_return - The TimestampsToReturn for each node, Both, Server, Source or None
  • max_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 to i32::MAX or greater, the server shall attempt to get a cached value.
§Returns
  • Ok(Vec<DataValue>) - A list of DataValue corresponding to each read operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of HistoryReadValueId of the nodes to apply the history read operation to.
§Returns
  • Ok(Vec<HistoryReadResult>) - A list of HistoryReadResult results corresponding to history read operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of WriteValue to be sent to the server.
§Returns
  • Ok(Vec<StatusCode>) - A list of StatusCode results corresponding to each write operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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:

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 of HistoryUpdateResult results corresponding to history update operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source§

impl Session

Source

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>) - A CallMethodResult for the Method call.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 a CallMethodRequest which includes a (NodeId, NodeId, Option<Vec<Variant>>) tuple which refers to the object id, method id, and input arguments respectively.
§Returns
  • Ok(CallMethodResult) - A CallMethodResult for the Method call.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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

Source

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 of AddNodesItem to be added to the server.
§Returns
  • Ok(Vec<AddNodesResult>) - A list of AddNodesResult corresponding to each add node operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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
§Returns
  • Ok(Vec<StatusCode>) - A list of StatusCode corresponding to each add reference operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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
§Returns
  • Ok(Vec<StatusCode>) - A list of StatusCode corresponding to each delete node operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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
§Returns
  • Ok(Vec<StatusCode>) - A list of StatusCode corresponding to each delete node operation.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source§

impl Session

Source

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 requests
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source§

impl Session

Source

pub fn subscription_state(&self) -> &Mutex<SubscriptionState>

Get the internal state of subscriptions registered on the session.

Source

pub fn trigger_publish_now(&self)

Trigger a publish to fire immediately.

Source

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 - true publishing 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 subscription
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 from create_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(()) - Success
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 - true publishing 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, Good or BadSubscriptionIdInvalid
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 - true the 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>) - The TransferResult for each transfer subscription.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 from create_subscription.
§Returns
  • Ok(StatusCode) - Service return code for the delete action, Good or BadSubscriptionIdInvalid
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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, Good or BadSubscriptionIdInvalid The 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.
Source

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 MonitoredItem
  • timestamps_to_return - An enumeration that specifies the timestamp Attributes to be transmitted for each MonitoredItem.
  • items_to_create - A list of MonitoredItemCreateRequest to be created and assigned to the specified Subscription.
§Returns
  • Ok(Vec<MonitoredItemCreateResult>) - A list of MonitoredItemCreateResult corresponding to the items to create. The size and order of the list matches the size and order of the items_to_create request parameter.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of MonitoredItemModifyRequest to modify.
§Returns
  • Ok(Vec<MonitoredItemModifyResult>) - A list of MonitoredItemModifyResult corresponding to the MonitoredItems to modify. The size and order of the list matches the size and order of the items_to_modify request parameter.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 items
  • monitored_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.
Source

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

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 the items_to_delete request parameter.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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

Source

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
§Returns
  • Ok(Vec<BrowseResult>) - A list BrowseResult corresponding to each node to browse. A browse result may contain a continuation point, for use with browse_next().
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 server
  • continuation_points - A list of BrowseDescription continuation points
§Returns
  • Ok(Option<Vec<BrowseResult>) - A list BrowseResult corresponding to each node to browse. A browse result may contain a continuation point, for use with browse_next().
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of BrowsePath node + relative path for the server to look up
§Returns
  • Ok(Vec<BrowsePathResult>>) - List of BrowsePathResult for the list of browse paths. The size and order of the list matches the size and order of the browse_paths parameter.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of NodeId nodes for the server to register
§Returns
  • Ok(Vec<NodeId>) - A list of NodeId corresponding to size and order of the input. The server may return an alias for the input NodeId
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

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 of NodeId nodes for the server to unregister
§Returns
  • Ok(()) - Request succeeded, server ignores invalid nodes
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source§

impl Session

Source

pub fn session_id(&self) -> u32

The internal ID of the session, used to keep track of multiple sessions in the same program.

Source

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.

Source

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.

Source

pub fn disable_reconnects(&self)

Disable automatic reconnects. This will make the event loop quit the next time it disconnects for whatever reason.

Source

pub fn enable_reconnects(&self)

Enable automatic reconnects. Automatically reconnecting is enabled by default.

Source

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.

Source

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

Source

pub async fn disconnect_without_delete_subscriptions( &self, ) -> Result<(), StatusCode>

Disconnect the server without deleting subscriptions, then wait until disconnected.

Source

pub fn decoding_options(&self) -> &DecodingOptions

Get the decoding options used by the session.

Source

pub fn channel(&self) -> &AsyncSecureChannel

Get a reference to the inner secure channel.

Source

pub fn request_handle(&self) -> IntegerId

Get the next request handle.

Source

pub fn encoding_context(&self) -> &RwLock<ContextOwned>

Get a reference to the global encoding context.

Source

pub fn endpoint_info(&self) -> &EndpointInfo

Get the target endpoint for the session.

Source

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.

Source

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.

Source

pub fn context(&self) -> Arc<RwLock<ContextOwned>>

Get a reference to the encoding

Source

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

Source

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

Return namespace array from server and store in namespace cache

Source

pub fn get_namespace_index_from_cache(&self, url: &str) -> Option<u16>

Return index of supplied namespace url from cache

Source

pub async fn get_namespace_index(&self, url: &str) -> Result<u16, Error>

Return index of supplied namespace url by first looking at namespace cache and querying server if necessary

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T