Server

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

Source§

impl Server

Source

pub fn new(config: ServerConfig) -> Server

Creates a new Server instance, initialising it from a ServerConfig.

Source

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.

Source

pub fn run_server(server: Arc<RwLock<Server>>)

Runs the supplied server and blocks until it completes either by aborting or by error.

Source

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.

Source

pub async fn new_server_task(server: Arc<RwLock<Server>>)

Returns the main server task - the loop that waits for connections and processes them.

Source

pub fn server_state(&self) -> Arc<RwLock<ServerState>>

Returns the current ServerState for the server.

Source

pub fn certificate_store(&self) -> Arc<RwLock<CertificateStore>>

Returns the CertificateStore for the server.

Source

pub fn address_space(&self) -> Arc<RwLock<AddressSpace>>

Returns the AddressSpace for the server.

Source

pub fn connections(&self) -> Arc<RwLock<Connections>>

Returns the Connections for the server.

Source

pub fn server_metrics(&self) -> Arc<RwLock<ServerMetrics>>

Returns the ServerMetrics for the server.

Source

pub fn single_threaded_executor(&self) -> bool

Returns the single_threaded_executor for the server.

Source

pub fn abort(&mut self)

Sets a flag telling the running server to abort. The abort will happen asynchronously after all sessions have disconnected.

Source

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.

Source

pub fn new_transport(&self) -> TcpTransport

Create a new transport.

Trait Implementations§

Source§

impl From<ServerConfig> for Server

Source§

fn from(config: ServerConfig) -> Server

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Server

§

impl !RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl !UnwindSafe for Server

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