pub struct Client(/* private fields */);
Expand description
Connected OPC UA client.
This represents an OPC UA client connected to a specific endpoint. Once a client is connected to an endpoint, it is not possible to switch to another server. Create a new client for that.
Once a connection to the given endpoint is established, the client keeps the connection open and reconnects if necessary.
If the connection fails unrecoverably, the client is no longer usable. In this case create a new client if required.
To disconnect, prefer method disconnect()
over simply dropping the client:
disconnection involves server communication and might take a short amount of time.
Implementations§
Source§impl Client
impl Client
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()
.
§Errors
§Panics
Sourcepub fn into_async(self) -> AsyncClient
pub fn into_async(self) -> AsyncClient
Turns client into AsyncClient
.
The AsyncClient
can be used to access methods in an asynchronous way.
Sourcepub fn state(&self) -> ClientState
pub fn state(&self) -> ClientState
Gets current channel and session state, and connect status.
Sourcepub fn disconnect(self)
pub 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.