pub struct ClientBuilder { /* private fields */ }Expand description
Client builder.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new() -> ClientBuilder
pub fn new() -> ClientBuilder
Creates a ClientBuilder
Sourcepub fn from_config(
path: impl Into<PathBuf>,
) -> Result<ClientBuilder, ConfigError>
pub fn from_config( path: impl Into<PathBuf>, ) -> Result<ClientBuilder, ConfigError>
Creates a ClientBuilder using a configuration file as the initial state.
Sourcepub fn client(self) -> Result<Client, Vec<String>>
pub fn client(self) -> Result<Client, Vec<String>>
Yields a Client from the values set by the builder. If the builder is not in a valid state
it will return a list of errors.
Sourcepub fn config(&self) -> &ClientConfig
pub fn config(&self) -> &ClientConfig
Get a reference to the internal ClientConfig.
Sourcepub fn config_mut(&mut self) -> &mut ClientConfig
pub fn config_mut(&mut self) -> &mut ClientConfig
Get a mutable reference to the internal ClientConfig.
Sourcepub fn into_config(self) -> ClientConfig
pub fn into_config(self) -> ClientConfig
Yields a ClientConfig from the values set by the builder.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Tests if the builder is in a valid state to be able to yield a Client.
Sourcepub fn application_name(
self,
application_name: impl Into<String>,
) -> ClientBuilder
pub fn application_name( self, application_name: impl Into<String>, ) -> ClientBuilder
Sets the application name.
Sourcepub fn application_uri(
self,
application_uri: impl Into<String>,
) -> ClientBuilder
pub fn application_uri( self, application_uri: impl Into<String>, ) -> ClientBuilder
Sets the application uri
Sourcepub fn product_uri(self, product_uri: impl Into<String>) -> ClientBuilder
pub fn product_uri(self, product_uri: impl Into<String>) -> ClientBuilder
Sets the product uri.
Sourcepub fn create_sample_keypair(self, create_sample_keypair: bool) -> ClientBuilder
pub fn create_sample_keypair(self, create_sample_keypair: bool) -> ClientBuilder
Sets whether the client should generate its own key pair if there is none found in the pki directory.
Sourcepub fn certificate_path(
self,
certificate_path: impl Into<PathBuf>,
) -> ClientBuilder
pub fn certificate_path( self, certificate_path: impl Into<PathBuf>, ) -> ClientBuilder
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.
Sourcepub fn private_key_path(
self,
private_key_path: impl Into<PathBuf>,
) -> ClientBuilder
pub fn private_key_path( self, private_key_path: impl Into<PathBuf>, ) -> ClientBuilder
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.
Sourcepub fn trust_server_certs(self, trust_server_certs: bool) -> ClientBuilder
pub fn trust_server_certs(self, trust_server_certs: bool) -> ClientBuilder
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.
Sourcepub fn verify_server_certs(self, verify_server_certs: bool) -> ClientBuilder
pub fn verify_server_certs(self, verify_server_certs: bool) -> ClientBuilder
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.
Sourcepub fn pki_dir(self, pki_dir: impl Into<PathBuf>) -> ClientBuilder
pub fn pki_dir(self, pki_dir: impl Into<PathBuf>) -> ClientBuilder
Sets the pki directory where client’s own key pair is stored and where /trusted and
/rejected server certificates are stored.
Sourcepub fn preferred_locales(self, preferred_locales: Vec<String>) -> ClientBuilder
pub fn preferred_locales(self, preferred_locales: Vec<String>) -> ClientBuilder
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.
Sourcepub fn default_endpoint(self, endpoint_id: impl Into<String>) -> ClientBuilder
pub fn default_endpoint(self, endpoint_id: impl Into<String>) -> ClientBuilder
Sets the id of the default endpoint to connect to.
Sourcepub fn endpoint(
self,
endpoint_id: impl Into<String>,
endpoint: ClientEndpoint,
) -> ClientBuilder
pub fn endpoint( self, endpoint_id: impl Into<String>, endpoint: ClientEndpoint, ) -> ClientBuilder
Adds an endpoint to the list of endpoints the client knows of.
Sourcepub fn endpoints(
self,
endpoints: Vec<(impl Into<String>, ClientEndpoint)>,
) -> ClientBuilder
pub fn endpoints( self, endpoints: Vec<(impl Into<String>, ClientEndpoint)>, ) -> ClientBuilder
Adds multiple endpoints to the list of endpoints the client knows of.
Sourcepub fn user_token(
self,
user_token_id: impl Into<String>,
user_token: ClientUserToken,
) -> ClientBuilder
pub fn user_token( self, user_token_id: impl Into<String>, user_token: ClientUserToken, ) -> ClientBuilder
Adds a user token to the list supported by the client.
Sourcepub fn channel_lifetime(self, channel_lifetime: u32) -> ClientBuilder
pub fn channel_lifetime(self, channel_lifetime: u32) -> ClientBuilder
Requested secure channel token lifetime, in milliseconds. The channel will be renewed once 3/4 of the lifetime has elapsed. Setting this too low is likely to cause issues.
Sourcepub fn session_retry_limit(self, session_retry_limit: i32) -> ClientBuilder
pub fn session_retry_limit(self, session_retry_limit: i32) -> ClientBuilder
Sourcepub fn session_retry_initial(
self,
session_retry_initial: Duration,
) -> ClientBuilder
pub fn session_retry_initial( self, session_retry_initial: Duration, ) -> ClientBuilder
Initial time between retries when backing off on session reconnects.
Sourcepub fn session_retry_max(self, session_retry_max: Duration) -> ClientBuilder
pub fn session_retry_max(self, session_retry_max: Duration) -> ClientBuilder
Maximum time between retries when backing off on session reconnects.
Sourcepub fn keep_alive_interval(self, keep_alive_interval: Duration) -> ClientBuilder
pub fn keep_alive_interval(self, keep_alive_interval: Duration) -> ClientBuilder
Time between making simple Read requests to the server to check for liveness and avoid session timeouts.
Sourcepub fn max_array_length(self, max_array_length: usize) -> ClientBuilder
pub fn max_array_length(self, max_array_length: usize) -> ClientBuilder
Maximum number of array elements. 0 actually means 0, i.e. no array permitted
Sourcepub fn max_byte_string_length(
self,
max_byte_string_length: usize,
) -> ClientBuilder
pub fn max_byte_string_length( self, max_byte_string_length: usize, ) -> ClientBuilder
Maximum length in bytes of a byte string. 0 actually means 0, i.e. no byte strings permitted.
Sourcepub fn max_chunk_count(self, max_chunk_count: usize) -> ClientBuilder
pub fn max_chunk_count(self, max_chunk_count: usize) -> ClientBuilder
Sets the maximum number of chunks in an outgoing message. 0 means no limit.
Sourcepub fn max_chunk_size(self, max_chunk_size: usize) -> ClientBuilder
pub fn max_chunk_size(self, max_chunk_size: usize) -> ClientBuilder
Maximum size of each individual outgoing message chunk.
Sourcepub fn max_incoming_chunk_size(
self,
max_incoming_chunk_size: usize,
) -> ClientBuilder
pub fn max_incoming_chunk_size( self, max_incoming_chunk_size: usize, ) -> ClientBuilder
Maximum size of each incoming chunk.
Sourcepub fn max_message_size(self, max_message_size: usize) -> ClientBuilder
pub fn max_message_size(self, max_message_size: usize) -> ClientBuilder
Sets the maximum outgoing message size in bytes. 0 means no limit.
Sourcepub fn max_string_length(self, max_string_length: usize) -> ClientBuilder
pub fn max_string_length(self, max_string_length: usize) -> ClientBuilder
Maximum length in bytes of a string. 0 actually means 0, i.e. no string permitted.
Sourcepub fn max_failed_keep_alive_count(
self,
max_failed_keep_alive_count: u64,
) -> ClientBuilder
pub fn max_failed_keep_alive_count( self, max_failed_keep_alive_count: u64, ) -> ClientBuilder
Maximum number of failed keep alives before the client will be forcibly closed. Set this to zero to never close the connection due to failed keepalives.
Note that this should not be necessary to set if the server is compliant, only if it ends up in a bad state that cannot be recovered from easily.
Sourcepub fn request_timeout(self, request_timeout: Duration) -> ClientBuilder
pub fn request_timeout(self, request_timeout: Duration) -> ClientBuilder
Set the timeout on requests sent to the server.
Sourcepub fn publish_timeout(self, publish_timeout: Duration) -> ClientBuilder
pub fn publish_timeout(self, publish_timeout: Duration) -> ClientBuilder
Set the timeout on publish requests sent to the server.
Sourcepub fn min_publish_interval(
self,
min_publish_interval: Duration,
) -> ClientBuilder
pub fn min_publish_interval( self, min_publish_interval: Duration, ) -> ClientBuilder
Set the lowest allowed publishing interval by the client. The server may also enforce its own minimum.
Sourcepub fn ignore_clock_skew(self, ignore_clock_skew: bool) -> ClientBuilder
pub fn ignore_clock_skew(self, ignore_clock_skew: bool) -> ClientBuilder
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.
Sourcepub fn recreate_monitored_items_chunk(
self,
recreate_monitored_items_chunk: usize,
) -> ClientBuilder
pub fn recreate_monitored_items_chunk( self, recreate_monitored_items_chunk: usize, ) -> ClientBuilder
When a session is recreated on the server, the client will attempt to transfer monitored subscriptions from the old session to the new. This is the maximum number of monitored items to create per request.
Sourcepub fn recreate_subscriptions(
self,
recreate_subscriptions: bool,
) -> ClientBuilder
pub fn recreate_subscriptions( self, recreate_subscriptions: bool, ) -> ClientBuilder
Automatically recreate subscriptions on reconnect, by first calling
crate::Session::transfer_subscriptions, then attempting to recreate
subscriptions if that fails.
Defaults to true. Note that if you disable this feature, you will need to
handle cleanup of the subscriptions in the session yourself.
Sourcepub fn session_name(self, session_name: impl Into<String>) -> ClientBuilder
pub fn session_name(self, session_name: impl Into<String>) -> ClientBuilder
Session name - the default name to use for a new session
Sourcepub fn session_timeout(self, session_timeout: u32) -> ClientBuilder
pub fn session_timeout(self, session_timeout: u32) -> ClientBuilder
Sets the session timeout period, in milliseconds.
Sourcepub fn session_nonce_length(self, session_nonce_length: usize) -> ClientBuilder
pub fn session_nonce_length(self, session_nonce_length: usize) -> ClientBuilder
Set the length of the nonce generated for CreateSession requests.