pub struct Server { /* private fields */ }Expand description
A Server represents a running instance of an OPC UA server. There can be more than one Server
running at any given time providing they do not share the same ports.
A Server is initialised from a ServerConfig. The ServerConfig sets what port the server
runs on, the endpoints it supports, the identity tokens it supports, identity tokens and so forth.
A single server can offer multiple endpoints with different security policies. A server can
also be configured to register itself with a discovery server.
Once the Server is configured, it is run by calling run which consumes the Server.
Alternatively if you have reason to maintain access to the server object,
you may call the static function run_server providing the server wrapped as
Arc<RwLock<Server>>.
The server’s AddressSpace is initialised with the default OPC UA node set, but may also
be extended with additional nodes representing folders, variables, methods etc.
The server’s CertificateStore manages the server’s private key and public certificate. It
also manages public certificates of incoming clients and arranges them into trusted and rejected
collections.
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(config: ServerConfig) -> Server
pub fn new(config: ServerConfig) -> Server
Creates a new Server instance, initialising it from a ServerConfig.
Sourcepub fn run(self)
pub fn run(self)
Runs the server and blocks until it completes either by aborting or by error. Typically a server should be run on its own thread.
Calling this function consumes the server.
Sourcepub fn run_server(server: Arc<RwLock<Server>>)
pub fn run_server(server: Arc<RwLock<Server>>)
Runs the supplied server and blocks until it completes either by aborting or by error.
Sourcepub fn run_server_on_runtime<F>(
runtime: Runtime,
server_task: F,
block: bool,
) -> Option<JoinHandle<<F as Future>::Output>>
pub fn run_server_on_runtime<F>( runtime: Runtime, server_task: F, block: bool, ) -> Option<JoinHandle<<F as Future>::Output>>
Allow the server to be run on a caller supplied runtime. If block is set, the task runs to completion (abort or by error), otherwise, the task is spawned and a join handle is returned by the function. Spawning might be suitable if the runtime is being used for other async tasks.
Sourcepub async fn new_server_task(server: Arc<RwLock<Server>>)
pub async fn new_server_task(server: Arc<RwLock<Server>>)
Returns the main server task - the loop that waits for connections and processes them.
Sourcepub fn server_state(&self) -> Arc<RwLock<ServerState>>
pub fn server_state(&self) -> Arc<RwLock<ServerState>>
Returns the current ServerState for the server.
Sourcepub fn certificate_store(&self) -> Arc<RwLock<CertificateStore>>
pub fn certificate_store(&self) -> Arc<RwLock<CertificateStore>>
Returns the CertificateStore for the server.
Sourcepub fn address_space(&self) -> Arc<RwLock<AddressSpace>>
pub fn address_space(&self) -> Arc<RwLock<AddressSpace>>
Returns the AddressSpace for the server.
Sourcepub fn connections(&self) -> Arc<RwLock<Connections>>
pub fn connections(&self) -> Arc<RwLock<Connections>>
Returns the Connections for the server.
Sourcepub fn server_metrics(&self) -> Arc<RwLock<ServerMetrics>>
pub fn server_metrics(&self) -> Arc<RwLock<ServerMetrics>>
Returns the ServerMetrics for the server.
Sourcepub fn single_threaded_executor(&self) -> bool
pub fn single_threaded_executor(&self) -> bool
Returns the single_threaded_executor for the server.
Sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Sets a flag telling the running server to abort. The abort will happen asynchronously after all sessions have disconnected.
Sourcepub fn add_polling_action<F>(&mut self, interval_ms: u64, action: F)
pub fn add_polling_action<F>(&mut self, interval_ms: u64, action: F)
Creates a polling action that happens continuously on an interval while the server is running. For example, a server might run a polling action every 100ms to synchronous address space state between variables and their physical backends.
The function that is supplied does not take any arguments. It is expected that the implementation will move any variables into the function that are required to perform its action.
Sourcepub fn new_transport(&self) -> TcpTransport
pub fn new_transport(&self) -> TcpTransport
Create a new transport.