Struct opcua_server::server::Server
source · [−]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
sourceimpl 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>> where
F: Future + Send + 'static,
F::Output: Send + 'static,
pub fn run_server_on_runtime<F>(
runtime: Runtime,
server_task: F,
block: bool
) -> Option<JoinHandle<<F as Future>::Output>> where
F: Future + Send + 'static,
F::Output: Send + 'static,
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) where
F: Fn() + Send + Sync + 'static,
pub fn add_polling_action<F>(&mut self, interval_ms: u64, action: F) where
F: Fn() + Send + Sync + 'static,
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.
Trait Implementations
sourceimpl From<ServerConfig> for Server
impl From<ServerConfig> for Server
sourcefn from(config: ServerConfig) -> Server
fn from(config: ServerConfig) -> Server
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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