Skip to main content

ServerBuilder

Struct ServerBuilder 

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

Server builder, used to configure the server programatically, and for setting core components like node managers, authenticator, and type collections.

Implementations§

Source§

impl ServerBuilder

Source

pub fn new() -> ServerBuilder

Create a new server builder.

If the generated address space is enabled, this will add the core and diagnostic node managers.

Source

pub fn from_config(config: ServerConfig) -> ServerBuilder

Create a server builder from a config object.

Source

pub fn new_anonymous(application_name: impl Into<String>) -> ServerBuilder

Creates a simple endpoint that accepts anonymous connections.

Source

pub fn new_sample() -> ServerBuilder

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 config(&self) -> &ServerConfig

Get the currently configured config.

Source

pub fn with_config_from(self, path: impl Into<PathBuf>) -> ServerBuilder

Load config from a local file. Will panic if this fails, if you prefer to propagate errors use

with_config(ServerConfig::load(&"my_config.conf".into())?)

Source

pub fn with_config(self, config: ServerConfig) -> ServerBuilder

Set the entire config object, which may be loaded from somewhere else.

Source

pub fn config_mut(&mut self) -> &mut ServerConfig

Get a mutable reference to the currently configured config.

Source

pub fn limits_mut(&mut self) -> &mut Limits

Get a mutable reference to the limits object.

Source

pub fn with_node_manager( self, node_manager: impl NodeManagerBuilder + 'static, ) -> ServerBuilder

Add a node manager builder to the list of node managers. Once the server is created you can retrieve it from handle.node_managers(). This allows node managers to contain core server types without late initialization.

Source

pub fn without_node_managers(self) -> ServerBuilder

Clear all node managers.

Warning: your server will not be compliant without presenting the core namespace. If you remove the core node manager you must implement the core namespace yourself.

Source

pub fn with_authenticator( self, authenticator: Arc<dyn AuthManager>, ) -> ServerBuilder

Set a custom authenticator.

Source

pub fn with_type_tree_getter( self, type_tree_getter: Arc<dyn TypeTreeForUser>, ) -> ServerBuilder

Set a custom type tree getter. Most servers do not need to touch this.

The type tree getter gets a type tree for a specific user, letting you have different type trees for different users, which is relevant for some servers.

This is currently used for constructing event filters, and when building external references. You only need to set this if you intend to have types that are not in the global DefaultTypeTree.

Note that built in node managers do not use the type tree getter, if you want to have per-user types you need to implement a node manager that can correctly filter during browse, etc. This only lets you use the custom type tree for each individual user.

Source

pub fn build_info(self, build_info: BuildInfo) -> ServerBuilder

Set information about the application exposed to the user in the ServerStatus/BuildInfo variable on the server.

Source

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

Server application name.

Source

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

Server application URI.

Source

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

Server product URI.

Source

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

Autocreates public / private keypair if they do not exist.

Source

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

Path to a custom certificate, to be used instead of the default .der certificate

Source

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

Path to a custom private key, used instead of the default private key.

Source

pub fn trust_client_certs(self, trust_client_certs: bool) -> ServerBuilder

Auto trust client certificates. Typically should only be used for testing or samples, as it is potentially unsafe.

Source

pub fn check_cert_time(self, check_cert_time: bool) -> ServerBuilder

Validate the valid from/to fields of a certificate.

Source

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

PKI folder, either absolute or relative to executable.

Source

pub fn discovery_server_url(self, url: impl Into<String>) -> ServerBuilder

URL to a discovery server. Adding this makes the server attempt to register itself with this discovery server.

Source

pub fn hello_timeout(self, timeout: u32) -> ServerBuilder

Timeout for new connections to send a HELLO message, in seconds. After this timeout expires without a valid hello message, the connection is closed.

Source

pub fn host(self, host: impl Into<String>) -> ServerBuilder

Hostname to listen to incoming TCP connections on.

Source

pub fn port(self, port: u16) -> ServerBuilder

Port number used to listen for incoming TCP connections.

Source

pub fn limits(self, limits: Limits) -> ServerBuilder

General server limits.

Source

pub fn locale_ids(self, locale_ids: Vec<String>) -> ServerBuilder

Supported locale IDs.

Source

pub fn add_user_token( self, key: impl Into<String>, token: ServerUserToken, ) -> ServerBuilder

Add a user to the list of known user tokens. Used by the default authenticator, you can use a custom one instead.

Source

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

List of discovery endpoint URLs which may or may not be the same as the service endpoints.

Source

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

Default endpoint ID.

Source

pub fn add_endpoint( self, id: impl Into<String>, endpoint: impl Into<ServerEndpoint>, ) -> ServerBuilder

Add an endpoint to the list of endpoints supported by the server.

Source

pub fn subscription_poll_interval_ms(self, interval: u64) -> ServerBuilder

Interval in milliseconds between each time the subscriptions are polled.

Source

pub fn publish_timeout_default_ms(self, timeout: u64) -> ServerBuilder

Default publish request timeout.

Source

pub fn max_timeout_ms(self, timeout: u32) -> ServerBuilder

Max message timeout for non-publish requests. Will not be applied for requests that are handled synchronously. Set to 0 for no timeout, meaning that a timeout will only be applied if the client requests one. If this is greater than zero and the client requests a timeout of 0, this will be used.

Source

pub fn max_secure_channel_token_lifetime_ms( self, lifetime: u32, ) -> ServerBuilder

Maximum lifetime of secure channel tokens. The client will request a number, this just sets an upper limit on that value. Note that there is no lower limit, if a client sets an expiry of 0, we will just instantly time out.

Source

pub fn build(self) -> Result<(Server, ServerHandle), String>

Try to construct a server from this builder, may fail if the configuration is invalid.

Source

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

Maximum length of arrays when encoding or decoding messages.

Source

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

Maximum length of strings in bytes when encoding or decoding messages.

Source

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

Maximum byte string length in bytes when encoding or decoding messages.

Source

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

Maximum allowed message size in bytes.

Source

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

Maximum allowed chunk count per message.

Source

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

Maximum send buffer size, can be negotiated lower with clients.

Source

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

Maximum receive buffer size, can be negotiated lower with clients.

Source

pub fn max_browse_continuation_points( self, max_browse_continuation_points: usize, ) -> ServerBuilder

Maximum number of browse continuation points per session.

Source

pub fn max_history_continuation_points( self, max_history_continuation_points: usize, ) -> ServerBuilder

Maximum number of history continuation points per session.

Source

pub fn max_query_continuation_points( self, max_query_continuation_points: usize, ) -> ServerBuilder

Maximum number of query continuation points per session.

Source

pub fn max_sessions(self, max_sessions: usize) -> ServerBuilder

Maximum number of active sessions.

Source

pub fn max_session_timeout_ms( self, max_session_timeout_ms: u64, ) -> ServerBuilder

Maximum time in milliseconds a session can be inactive before it is timed out and removed. The client can request a lower value than this.

Source

pub fn token(self, token: CancellationToken) -> ServerBuilder

Set the cancellation token used by the server. You only need to set the token if you need to use a token from somewhere else to cancel, otherwise you can get the token after building the server with handle.token().

Source

pub fn with_type_loader(self, loader: Arc<dyn TypeLoader>) -> ServerBuilder

Register a type loader. Any deserialization will use this type loader to handle types coming from the user.

If the user sends a type not in any registered type loader, decoding will fail.

Source

pub fn diagnostics_enabled(self, enabled: bool) -> ServerBuilder

Set whether to enable diagnostics on the server or not. Only users with the right permissions can read the diagnostics

Trait Implementations§

Source§

impl Default for ServerBuilder

Source§

fn default() -> ServerBuilder

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