Struct Client

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

Wrapper around common data for generating sessions and performing requests with one-shot connections.

Implementations§

Source§

impl Client

Source

pub fn new(config: ClientConfig) -> Self

Create a new client from config.

Note that this does not make any connection to the server.

§Arguments
  • config - Client configuration object.
Source

pub fn session_builder(&self) -> SessionBuilder<'_, (), ()>

Get a new session builder that can be used to build a session dynamically.

Source

pub async fn connect_to_endpoint_id( &mut self, endpoint_id: impl Into<String>, ) -> Result<(Arc<Session>, SessionEventLoop), StatusCode>

Connects to a named endpoint that you have defined in the ClientConfig and creates a Session for that endpoint. Note that GetEndpoints is first called on the server and it is expected to support the endpoint you intend to connect to.

§Returns
  • Ok((Arc<Session>, SessionEventLoop)) - Session and event loop.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub async fn connect_to_matching_endpoint( &mut self, endpoint: impl Into<EndpointDescription>, user_identity_token: IdentityToken, ) -> Result<(Arc<Session>, SessionEventLoop), StatusCode>

Connects to an ad-hoc server endpoint description.

This function returns both a reference to the session, and a SessionEventLoop. You must run and poll the event loop in order to actually establish a connection.

This method will not attempt to create a session on the server, that will only happen once you start polling the session event loop.

§Arguments
  • endpoint - Discovery endpoint, the client will first connect to this in order to get a list of the available endpoints on the server.
  • user_identity_token - Identity token to use for authentication.
§Returns
  • Ok((Arc<Session>, SessionEventLoop)) - Session and event loop.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub fn connect_to_endpoint_directly( &mut self, endpoint: impl Into<EndpointDescription>, identity_token: IdentityToken, ) -> Result<(Arc<Session>, SessionEventLoop), String>

Connects to a server directly using provided EndpointDescription.

This function returns both a reference to the session, and a SessionEventLoop. You must run and poll the event loop in order to actually establish a connection.

This method will not attempt to create a session on the server, that will only happen once you start polling the session event loop.

§Arguments
  • endpoint - Endpoint to connect to.
  • identity_token - Identity token for authentication.
§Returns
  • Ok((Arc<Session>, SessionEventLoop)) - Session and event loop.
  • Err(String) - Endpoint is invalid.
Source

pub async fn connect_to_default_endpoint( &mut self, ) -> Result<(Arc<Session>, SessionEventLoop), String>

Creates a new Session using the default endpoint specified in the config. If there is no default, or the endpoint does not exist, this function will return an error

This function returns both a reference to the session, and a SessionEventLoop. You must run and poll the event loop in order to actually establish a connection.

This method will not attempt to create a session on the server, that will only happen once you start polling the session event loop.

§Arguments
§Returns
  • Ok((Arc<Session>, SessionEventLoop)) - Session and event loop.
  • Err(String) - Endpoint is invalid.
Source

pub fn default_endpoint(&self) -> Result<ClientEndpoint, String>

Gets the ClientEndpoint information for the default endpoint, as defined by the configuration. If there is no default endpoint, this function will return an error.

§Returns
  • Ok(ClientEndpoint) - The default endpoint set in config.
  • Err(String) - No default endpoint could be found.
Source

pub async fn get_server_endpoints( &self, ) -> Result<Vec<EndpointDescription>, StatusCode>

Get the list of endpoints for the server at the configured default endpoint.

§Returns
  • Ok(Vec<EndpointDescription>) - A list of the available endpoints on the server.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub async fn get_server_endpoints_from_url( &self, server_url: impl Into<String>, ) -> Result<Vec<EndpointDescription>, StatusCode>

Get the list of endpoints for the server at the given URL.

§Arguments
  • server_url - URL of the discovery server to get endpoints from.
§Returns
  • Ok(Vec<EndpointDescription>) - A list of the available endpoints on the server.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub async fn get_endpoints( &self, server_url: impl Into<String>, locale_ids: &[&str], profile_uris: &[&str], ) -> Result<Vec<EndpointDescription>, StatusCode>

Get the list of endpoints for the server at the given URL.

§Arguments
  • server_url - URL of the discovery server to get endpoints from.
  • locale_ids - List of required locale IDs on the given server endpoint.
  • profile_uris - Returned endpoints should match one of these profile URIs.
§Returns
  • Ok(Vec<EndpointDescription>) - A list of the available endpoints on the server.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub async fn find_servers( &self, discovery_endpoint_url: impl Into<String>, locale_ids: Option<Vec<UAString>>, server_uris: Option<Vec<UAString>>, ) -> Result<Vec<ApplicationDescription>, StatusCode>

Connects to a discovery server and asks the server for a list of available servers’ ApplicationDescription.

§Arguments
  • discovery_endpoint_url - Discovery endpoint to connect to.
  • locale_ids - List of locales to use.
  • server_uris - List of servers to return. If empty, all known servers are returned.
§Returns
  • Ok(Vec<ApplicationDescription>) - List of descriptions for servers known to the discovery server.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub async fn find_servers_on_network( &self, discovery_endpoint_url: impl Into<String>, starting_record_id: u32, max_records_to_return: u32, server_capability_filter: Option<Vec<UAString>>, ) -> Result<FindServersOnNetworkResponse, StatusCode>

Connects to a discovery server and asks for a list of available servers on the network.

See OPC UA Part 4 - Services 5.5.3 for a complete description of the service.

§Arguments
  • discovery_endpoint_url - Endpoint URL to connect to.
  • starting_record_id - Only records with an identifier greater than this number will be returned.
  • max_records_to_return - The maximum number of records to return in the response. 0 indicates that there is no limit.
  • server_capability_filter - List of server capability filters. Only records with all the specified server capabilities are returned.
§Returns
  • Ok(FindServersOnNetworkResponse) - Full service response object.
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub fn find_matching_endpoint( endpoints: &[EndpointDescription], endpoint_url: &str, security_policy: SecurityPolicy, security_mode: MessageSecurityMode, ) -> Option<EndpointDescription>

Find an endpoint supplied from the list of endpoints that matches the input criteria.

§Arguments
  • endpoints - List of available endpoints on the server.
  • endpoint_url - Given endpoint URL.
  • security_policy - Required security policy.
  • security_mode - Required security mode.
§Returns
  • Some(EndpointDescription) - Validated endpoint.
  • None - No matching endpoint was found.
Source

pub fn is_supported_endpoint(&self, endpoint: &EndpointDescription) -> bool

Determine if we recognize the security of this endpoint.

§Arguments
  • endpoint - Endpoint to check.
§Returns
  • bool - true if the endpoint is supported.
Source

pub async fn register_server( &mut self, discovery_endpoint_url: impl Into<String>, server: RegisteredServer, ) -> Result<(), StatusCode>

This function is used by servers that wish to register themselves with a discovery server. i.e. one server is the client to another server. The server sends a RegisterServerRequest to the discovery server to register itself. Servers are expected to re-register themselves periodically with the discovery server, with a maximum of 10 minute intervals.

See OPC UA Part 4 - Services 5.4.5 for complete description of the service and error responses.

§Arguments
  • server - The server to register
§Returns
  • Ok(()) - Success
  • Err(StatusCode) - Request failed, Status code is the reason for failure.
Source

pub fn certificate_store(&self) -> &Arc<RwLock<CertificateStore>>

Get the certificate store.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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