Struct opcua_server::builder::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
sourceimpl 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 where
T: Into<String>,
pub fn new_anonymous<T>(application_name: T) -> Self where
T: Into<String>,
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 where
T: Into<String>,
pub fn application_name<T>(self, application_name: T) -> Self where
T: Into<String>,
Sets the application name.
sourcepub fn application_uri<T>(self, application_uri: T) -> Self where
T: Into<String>,
pub fn application_uri<T>(self, application_uri: T) -> Self where
T: Into<String>,
Sets the application uri
sourcepub fn product_uri<T>(self, product_uri: T) -> Self where
T: Into<String>,
pub fn product_uri<T>(self, product_uri: T) -> Self where
T: Into<String>,
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 where
T: Into<PathBuf>,
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.
sourcepub fn private_key_path<T>(self, private_key_path: T) -> Self where
T: Into<PathBuf>,
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.
sourcepub fn pki_dir<T>(self, pki_dir: T) -> Self where
T: Into<PathBuf>,
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.
sourcepub fn endpoint<T>(self, endpoint_id: T, endpoint: ServerEndpoint) -> Self where
T: Into<String>,
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.
sourcepub fn endpoints<T>(self, endpoints: Vec<(T, ServerEndpoint)>) -> Self where
T: Into<String>,
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.
sourcepub fn user_token<T>(
self,
user_token_id: T,
user_token: ServerUserToken
) -> Self where
T: Into<String>,
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.
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 where
T: Into<String>,
pub fn host_and_port<T>(self, host: T, port: u16) -> Self where
T: Into<String>,
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: u32) -> Self
pub fn max_subscriptions(self, max_subscriptions: u32) -> Self
Set the maximum number of subscriptions in a session
sourcepub fn max_monitored_items_per_sub(
self,
max_monitored_items_per_sub: u32
) -> Self
pub fn max_monitored_items_per_sub(
self,
max_monitored_items_per_sub: u32
) -> Self
Set the maximum number of monitored items per subscription
sourcepub fn max_array_length(self, max_array_length: u32) -> Self
pub fn max_array_length(self, max_array_length: u32) -> Self
Set the max array length in elements
sourcepub fn max_string_length(self, max_string_length: u32) -> Self
pub fn max_string_length(self, max_string_length: u32) -> 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: u32) -> Self
pub fn max_byte_string_length(self, max_byte_string_length: u32) -> Self
Set the max bytestring length in bytes
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.
Auto Trait Implementations
impl RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl Sync for ServerBuilder
impl Unpin for ServerBuilder
impl UnwindSafe for ServerBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more