Skip to main content

ServerBuilder

Struct ServerBuilder 

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

The ServerBuilder is a builder for producing a Server. It is an alternative to constructing a ServerConfig from file or from scratch.

Implementations§

Source§

impl ServerBuilder

Source

pub fn new() -> Self

Source

pub fn from_config(config: ServerConfig) -> Self

Reads the config in as a starting point

Source

pub fn new_anonymous<T>(application_name: T) -> Self
where T: Into<String>,

Creates a simple endpoint that accepts anonymous connections

Source

pub fn new_sample() -> Self

Creates and yields a builder which is configured with the sample server configuration. Use this for testing and similar reasons. Do not rely upon this in production code because it could change.

Source

pub fn server(self) -> Option<Server>

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

Source

pub fn config(self) -> ServerConfig

Yields a [ClientConfig] from the values set by the builder.

Source

pub fn is_valid(&self) -> bool

Test if the builder can yield a server with the configuration supplied.

Source

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

Sets the application name.

Source

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

Sets the application uri

Source

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

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<T>(self, certificate_path: T) -> Self
where T: Into<PathBuf>,

Sets a custom server 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 server certificate from disk. The certificate can be in either the .der or .pem format.

Source

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

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 pki_dir<T>(self, pki_dir: T) -> Self
where T: Into<PathBuf>,

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

Source

pub fn endpoint<T>(self, endpoint_id: T, endpoint: ServerEndpoint) -> Self
where T: Into<String>,

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

Source

pub fn endpoints<T>(self, endpoints: Vec<(T, ServerEndpoint)>) -> Self
where T: Into<String>,

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

Source

pub fn user_token<T>( self, user_token_id: T, user_token: ServerUserToken, ) -> Self
where T: Into<String>,

Adds a user token to the server.

Source

pub fn discovery_server_url(self, discovery_server_url: Option<String>) -> Self

Sets the discovery server url that this server shall attempt to register itself with.

Source

pub fn host_and_port<T>(self, host: T, port: u16) -> Self
where T: Into<String>,

Sets the hostname and port to listen on

Source

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

Discovery endpoint urls - the urls of this server used by clients to get endpoints. If the url is relative, e.g. “/” then the code will make a url for you using the port/host settings as they are at the time this function is executed.

Source

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

Set the maximum number of subscriptions in a session

Source

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

Set the maximum number of monitored items per subscription

Source

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

Set the max array length in elements

Source

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

Set the max string length in characters, i.e. if you set max to 1000 characters, then with UTF-8 encoding potentially that’s 4000 bytes.

Source

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

Set the max bytestring length in bytes

Source

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

Set the maximum message size

Source

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

Set the max chunk count

Source

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

Source

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

Source

pub fn trust_client_certs(self) -> Self

Sets the server to automatically trust client certs. This subverts the authentication during handshake, so only do this if you understand the risks.

Source

pub fn clients_can_modify_address_space(self) -> Self

Set that clients can modify the address space, i.e. they can add or remove nodes through the node management service. By default, they cannot.

Source

pub fn single_threaded_executor(self) -> Self

Configures the server to use a single-threaded executor. The default executor uses a thread pool with a worker thread for each CPU core available on the system.

Source

pub fn multi_threaded_executor(self) -> Self

Configures the server to use a multi-threaded executor.

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.