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
impl ServerBuilder
pub fn new() -> Self
Sourcepub fn from_config(config: ServerConfig) -> Self
pub fn from_config(config: ServerConfig) -> Self
Reads the config in as a starting point
Sourcepub fn new_anonymous<T>(application_name: T) -> Self
pub fn new_anonymous<T>(application_name: T) -> Self
Creates a simple endpoint that accepts anonymous connections
Sourcepub fn new_sample() -> Self
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.
Sourcepub fn server(self) -> Option<Server>
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.
Sourcepub fn config(self) -> ServerConfig
pub fn config(self) -> ServerConfig
Yields a [ClientConfig] from the values set by the builder.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Test if the builder can yield a server with the configuration supplied.
Sourcepub fn application_name<T>(self, application_name: T) -> Self
pub fn application_name<T>(self, application_name: T) -> Self
Sets the application name.
Sourcepub fn application_uri<T>(self, application_uri: T) -> Self
pub fn application_uri<T>(self, application_uri: T) -> Self
Sets the application uri
Sourcepub fn product_uri<T>(self, product_uri: T) -> Self
pub fn product_uri<T>(self, product_uri: T) -> Self
Sets the product uri.
Sourcepub fn create_sample_keypair(self, create_sample_keypair: bool) -> Self
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.
Sourcepub fn certificate_path<T>(self, certificate_path: T) -> Self
pub fn certificate_path<T>(self, certificate_path: T) -> Self
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.
Sourcepub fn private_key_path<T>(self, private_key_path: T) -> Self
pub fn private_key_path<T>(self, private_key_path: T) -> 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.
Sourcepub fn pki_dir<T>(self, pki_dir: T) -> Self
pub fn pki_dir<T>(self, pki_dir: T) -> Self
Sets the pki directory where client’s own key pair is stored and where /trusted and
/rejected server certificates are stored.
Sourcepub fn endpoint<T>(self, endpoint_id: T, endpoint: ServerEndpoint) -> Self
pub fn endpoint<T>(self, endpoint_id: T, endpoint: ServerEndpoint) -> Self
Adds an endpoint to the list of endpoints the client knows of.
Sourcepub fn endpoints<T>(self, endpoints: Vec<(T, ServerEndpoint)>) -> Self
pub fn endpoints<T>(self, endpoints: Vec<(T, ServerEndpoint)>) -> Self
Adds multiple endpoints to the list of endpoints the client knows of.
Sourcepub fn user_token<T>(
self,
user_token_id: T,
user_token: ServerUserToken,
) -> Self
pub fn user_token<T>( self, user_token_id: T, user_token: ServerUserToken, ) -> Self
Adds a user token to the server.
Sourcepub fn discovery_server_url(self, discovery_server_url: Option<String>) -> Self
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.
Sourcepub fn host_and_port<T>(self, host: T, port: u16) -> Self
pub fn host_and_port<T>(self, host: T, port: u16) -> Self
Sets the hostname and port to listen on
Sourcepub fn discovery_urls(self, discovery_urls: Vec<String>) -> Self
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.
Sourcepub fn max_subscriptions(self, max_subscriptions: usize) -> Self
pub fn max_subscriptions(self, max_subscriptions: usize) -> Self
Set the maximum number of subscriptions in a session
Sourcepub fn max_monitored_items_per_sub(
self,
max_monitored_items_per_sub: usize,
) -> Self
pub fn max_monitored_items_per_sub( self, max_monitored_items_per_sub: usize, ) -> Self
Set the maximum number of monitored items per subscription
Sourcepub fn max_array_length(self, max_array_length: usize) -> Self
pub fn max_array_length(self, max_array_length: usize) -> Self
Set the max array length in elements
Sourcepub fn max_string_length(self, max_string_length: usize) -> Self
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.
Sourcepub fn max_byte_string_length(self, max_byte_string_length: usize) -> Self
pub fn max_byte_string_length(self, max_byte_string_length: usize) -> Self
Set the max bytestring length in bytes
Sourcepub fn max_message_size(self, max_message_size: usize) -> Self
pub fn max_message_size(self, max_message_size: usize) -> Self
Set the maximum message size
Sourcepub fn max_chunk_count(self, max_chunk_count: usize) -> Self
pub fn max_chunk_count(self, max_chunk_count: usize) -> Self
Set the max chunk count
pub fn send_buffer_size(self, send_buffer_size: usize) -> Self
pub fn receive_buffer_size(self, receive_buffer_size: usize) -> Self
Sourcepub fn trust_client_certs(self) -> Self
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.
Sourcepub fn clients_can_modify_address_space(self) -> Self
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.
Sourcepub fn single_threaded_executor(self) -> Self
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.
Sourcepub fn multi_threaded_executor(self) -> Self
pub fn multi_threaded_executor(self) -> Self
Configures the server to use a multi-threaded executor.