pub struct ClientBuilder { /* private fields */ }
Expand description

The ClientBuilder is a builder for producing a Client. It is an alternative to constructing a ClientConfig from file or from scratch.

Example

use opcua_client::prelude::*;

fn main() {
    let builder = ClientBuilder::new()
        .application_name("OPC UA Sample Client")
        .application_uri("urn:SampleClient")
        .pki_dir("./pki")
        .endpoints(vec![
            ("sample_endpoint", ClientEndpoint {
                url: String::from("opc.tcp://127.0.0.1:4855/"),
                security_policy: String::from(SecurityPolicy::None.to_str()),
                security_mode: String::from(MessageSecurityMode::None),
                user_token_id: ANONYMOUS_USER_TOKEN_ID.to_string(),
            }),
        ])
        .default_endpoint("sample_endpoint")
        .create_sample_keypair(true)
        .trust_server_certs(true)
        .user_token("sample_user", ClientUserToken::user_pass("sample1", "sample1pwd"));
    let client = builder.client().unwrap();
}

Implementations

Creates a ClientBuilder

Creates a ClientBuilder using a configuration file as the initial state.

Yields a Client from the values set by the builder. If the builder is not in a valid state it will return None.

Yields a ClientConfig from the values set by the builder.

Tests if the builder is in a valid state to be able to yield a Client.

Sets the application name.

Sets the application uri

Sets the product uri.

Sets whether the client should generate its own key pair if there is none found in the pki directory.

Sets a custom client certificate path. The path is required to be provided as a partial path relative to the PKI directory. If set, this path will be used to read the client certificate from disk. The certificate can be in either the .der or .pem format.

Sets a custom private key path. The path is required to be provided as a partial path relative to the PKI directory. If set, this path will be used to read the private key from disk.

Sets whether the client should automatically trust servers. If this is not set then the client will reject the server upon first connect and the server’s certificate must be manually moved from pki’s /rejected folder to the /trusted folder. If it is set, then the server cert will automatically be stored in the /trusted folder.

Sets whether the client should verify server certificates. Regardless of this setting, server certificates are always checked to see if they are trusted and have a valid key length. In addition (if verify_server_certs is unset or is set to true) it will verify the hostname, application uri and the not before / after values to ensure validity.

Sets the pki directory where client’s own key pair is stored and where /trusted and /rejected server certificates are stored.

Sets the preferred locales of the client. These are passed to the server during session creation to ensure localized strings are in the preferred language.

Sets the id of the default endpoint to connect to.

Adds an endpoint to the list of endpoints the client knows of.

Adds multiple endpoints to the list of endpoints the client knows of.

Adds a user token to the list supported by the client.

Sets the session retry limit.

Sets the session retry interval.

Sets the session timeout period.

Sets whether the client should ignore clock skew so the client can make a successful connection to the server, even when the client and server clocks are out of sync.

Configures the client to use a single-threaded executor. This reduces the number of threads used by the client.

Configures the client to use a multi-threaded executor.

Session name - the default name to use for a new session

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.