Skip to main content

Client

Struct Client 

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

An OPC-UA client. SecurityMode None by default; call set_security (feature crypto) for a secured SecurityPolicy.

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

Creates a fresh, unconnected client.

Source

pub fn session_id(&self) -> &NodeId

The activated session id (null until connected).

Source

pub fn open_channel<T: Transport>( &mut self, transport: &mut T, endpoint_url: &str, ) -> Result<(), ClientError>

Opens just the transport + SecureChannel (Hello + OpenSecureChannel), without a session — enough for the session-less Discovery services (get_endpoints / find_servers).

§Errors

ClientError on a Hello/OpenSecureChannel failure.

Source

pub fn connect<T: Transport>( &mut self, transport: &mut T, endpoint_url: &str, ) -> Result<(), ClientError>

Runs the full connect handshake: Hello, OpenSecureChannel, CreateSession, ActivateSession.

§Errors

ClientError on any handshake step failing.

Source

pub fn read_values<T: Transport>( &mut self, transport: &mut T, node_ids: &[NodeId], ) -> Result<Vec<DataValue>, ClientError>

Reads the Value attribute of each node.

§Errors

ClientError if not connected or the service fails.

Source

pub fn write_values<T: Transport>( &mut self, transport: &mut T, writes: &[(NodeId, DataValue)], ) -> Result<Vec<u32>, ClientError>

Writes the Value attribute of each (node, value) pair, returning one StatusCode per write.

§Errors

ClientError if not connected or the service fails.

Source

pub fn get_endpoints<T: Transport>( &mut self, transport: &mut T, endpoint_url: &str, ) -> Result<Vec<EndpointDescription>, ClientError>

Calls the session-less Discovery service GetEndpoints (Part 4 §5.5.4). Requires only an open channel (open_channel or a full connect).

§Errors

ClientError if the channel is not open or the service fails.

Source

pub fn find_servers<T: Transport>( &mut self, transport: &mut T, endpoint_url: &str, ) -> Result<Vec<ApplicationDescription>, ClientError>

Calls the session-less Discovery service FindServers (Part 4 §5.5.2).

§Errors

ClientError if the channel is not open or the service fails.

Source

pub fn create_subscription<T: Transport>( &mut self, transport: &mut T, ) -> Result<u32, ClientError>

Creates a subscription with default parameters and returns its id.

§Errors

ClientError if not connected or the service fails.

Source

pub fn create_monitored_items<T: Transport>( &mut self, transport: &mut T, subscription_id: u32, items: &[(NodeId, u32)], ) -> Result<Vec<MonitoredItemCreateResult>, ClientError>

Creates monitored items (one per (node, client_handle)) on a subscription and returns the per-item results.

§Errors

ClientError if not connected or the service fails.

Source

pub fn publish<T: Transport>( &mut self, transport: &mut T, ) -> Result<(u32, Vec<MonitoredItemNotification>), ClientError>

Sends a Publish and returns (subscriptionId, changed monitored items) decoded from the response’s DataChangeNotification(s).

§Errors

ClientError if not connected or the service fails.

Source

pub fn delete_subscriptions<T: Transport>( &mut self, transport: &mut T, subscription_ids: &[u32], ) -> Result<Vec<u32>, ClientError>

Deletes subscriptions and returns the per-subscription StatusCodes.

§Errors

ClientError if not connected or the service fails.

Source

pub fn browse<T: Transport>( &mut self, transport: &mut T, node_id: NodeId, ) -> Result<Vec<ReferenceDescription>, ClientError>

Browses a node’s forward hierarchical references (all reference types, all node classes, full result mask) and returns the references found.

§Errors

ClientError if not connected or the service fails.

Source

pub fn call_method<T: Transport>( &mut self, transport: &mut T, object_id: NodeId, method_id: NodeId, input_arguments: Vec<Variant>, ) -> Result<CallMethodResult, ClientError>

Calls a method and returns its result.

§Errors

ClientError if not connected or the service fails.

Trait Implementations§

Source§

impl Debug for Client

Source§

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

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

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a 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.