Struct ClientBuilder

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

Client builder.

Implementations§

Source§

impl ClientBuilder

Source

pub fn new() -> ClientBuilder

Creates a ClientBuilder

Source

pub fn from_config( path: impl Into<PathBuf>, ) -> Result<ClientBuilder, ConfigError>

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

Source

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.

Source

pub fn config(self) -> ClientConfig

Yields a ClientConfig from the values set by the builder.

Source

pub fn is_valid(&self) -> bool

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

Source

pub fn application_name(self, application_name: impl Into<String>) -> Self

Sets the application name.

Source

pub fn application_uri(self, application_uri: impl Into<String>) -> Self

Sets the application uri

Source

pub fn product_uri(self, product_uri: impl Into<String>) -> Self

Sets the product uri.

Source

pub fn create_sample_keypair(self, create_sample_keypair: bool) -> Self

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

Source

pub fn certificate_path(self, certificate_path: impl Into<PathBuf>) -> Self

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.

Source

pub fn private_key_path(self, private_key_path: impl Into<PathBuf>) -> Self

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.

Source

pub fn trust_server_certs(self, trust_server_certs: bool) -> Self

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.

Source

pub fn verify_server_certs(self, verify_server_certs: bool) -> Self

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.

Source

pub fn pki_dir(self, pki_dir: impl Into<PathBuf>) -> Self

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

Source

pub fn preferred_locales(self, preferred_locales: Vec<String>) -> Self

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.

Source

pub fn default_endpoint(self, endpoint_id: impl Into<String>) -> Self

Sets the id of the default endpoint to connect to.

Source

pub fn endpoint( self, endpoint_id: impl Into<String>, endpoint: ClientEndpoint, ) -> Self

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

Source

pub fn endpoints( self, endpoints: Vec<(impl Into<String>, ClientEndpoint)>, ) -> Self

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

Source

pub fn user_token( self, user_token_id: impl Into<String>, user_token: ClientUserToken, ) -> Self

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

Source

pub fn channel_lifetime(self, channel_lifetime: u32) -> Self

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.

Source

pub fn session_retry_limit(self, session_retry_limit: i32) -> Self

Sets the session retry limit.

§Panics

Panics if session_retry_limit is less -1.

Source

pub fn session_retry_initial(self, session_retry_initial: Duration) -> Self

Initial time between retries when backing off on session reconnects.

Source

pub fn session_retry_max(self, session_retry_max: Duration) -> Self

Maximum time between retries when backing off on session reconnects.

Source

pub fn keep_alive_interval(self, keep_alive_interval: Duration) -> Self

Time between making simple Read requests to the server to check for liveness and avoid session timeouts.

Source

pub fn max_array_length(self, max_array_length: usize) -> Self

Maximum number of array elements. 0 actually means 0, i.e. no array permitted

Source

pub fn max_byte_string_length(self, max_byte_string_length: usize) -> Self

Maximum length in bytes of a byte string. 0 actually means 0, i.e. no byte strings permitted.

Source

pub fn max_chunk_count(self, max_chunk_count: usize) -> Self

Sets the maximum number of chunks in an outgoing message. 0 means no limit.

Source

pub fn max_chunk_size(self, max_chunk_size: usize) -> Self

Maximum size of each individual outgoing message chunk.

Source

pub fn max_incoming_chunk_size(self, max_incoming_chunk_size: usize) -> Self

Maximum size of each incoming chunk.

Source

pub fn max_message_size(self, max_message_size: usize) -> Self

Sets the maximum outgoing message size in bytes. 0 means no limit.

Source

pub fn max_string_length(self, max_string_length: usize) -> Self

Maximum length in bytes of a string. 0 actually means 0, i.e. no string permitted.

Source

pub fn max_failed_keep_alive_count( self, max_failed_keep_alive_count: u64, ) -> Self

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.

Source

pub fn request_timeout(self, request_timeout: Duration) -> Self

Set the timeout on requests sent to the server.

Source

pub fn publish_timeout(self, publish_timeout: Duration) -> Self

Set the timeout on publish requests sent to the server.

Source

pub fn min_publish_interval(self, min_publish_interval: Duration) -> Self

Set the lowest allowed publishing interval by the client. The server may also enforce its own minimum.

Source

pub fn ignore_clock_skew(self, ignore_clock_skew: bool) -> Self

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.

Source

pub fn recreate_monitored_items_chunk( self, recreate_monitored_items_chunk: usize, ) -> Self

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.

Source

pub fn recreate_subscriptions(self, recreate_subscriptions: bool) -> Self

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.

Source

pub fn session_name(self, session_name: impl Into<String>) -> Self

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

Source

pub fn session_timeout(self, session_timeout: u32) -> Self

Sets the session timeout period, in milliseconds.

Trait Implementations§

Source§

impl Default for ClientBuilder

Source§

fn default() -> ClientBuilder

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> 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