Skip to main content

Server

Struct Server 

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

Stateful owner of station admission, registration, command dispatch, and event correlation.

Construction is inert: callers must poll Self::run. The server owns its listener or injected-ingress receiver and all registered session routing; integration code normally retains only the returned ServerHandle and event receiver after spawning the run future. Dropping the Server future directly is abrupt, so normal shutdown should use ServerHandle::shutdown and then await run.

Implementations§

Source§

impl Server

Source

pub fn with_observation_sender(self, sender: Sender<ServerObservation>) -> Self

Attaches a bounded, nonblocking stream of sanitized signaling records.

Queue saturation never delays phone traffic. Whole observations are discarded and the next delivered item reports the loss count.

Source

pub async fn bind( config: ServerConfig, definitions: impl IntoIterator<Item = DeviceDefinition>, ) -> Result<(Self, ServerHandle, Receiver<Event>), ServerError>

Bind the configured plain TCP endpoint and construct a server.

The returned tuple contains the inert server, its cloneable command handle, and the sole event receiver. Call Self::local_addr after construction when config.bind used port zero, then spawn or await Self::run. This constructor classifies every accepted connection as StationTransport::Clear. Use Self::with_ingress when transport negotiation or multiple listeners are owned elsewhere.

Source

pub fn with_ingress( config: ServerConfig, definitions: impl IntoIterator<Item = DeviceDefinition>, ) -> Result<(Self, ServerHandle, Receiver<Event>, ServerIngress), ServerError>

Construct a server whose ready station streams are supplied externally.

The additional ServerIngress value is cloned by clear and secure listener tasks. Each task completes its transport setup, preserves the accepted peer and local socket addresses, and submits the stream with an accurate StationTransport classification. The returned server has no bound listener, so Self::local_addr is unavailable.

Source

pub fn local_addr(&self) -> Result<SocketAddr, ServerError>

Return the concrete address owned by Self::bind.

This exposes an operating-system-assigned port when the requested bind address used port zero. Servers created by Self::with_ingress return ServerError::InvalidConfig because listener addresses belong to the external transport owner.

Source

pub async fn run(self) -> Result<(), ServerError>

Drive admission, command dispatch, reconfiguration, and shutdown.

This consuming future must be polled exactly once. It accepts plain sockets owned by Self::bind and streams submitted through ServerIngress, starts an independent session task for each, and serializes server-wide commands. It returns normally after an explicit shutdown request or after every ServerHandle is dropped; before returning it asks each registered session to disconnect. Listener or server-level I/O failures are returned as ServerError, while an individual session failure is emitted as Event::SessionError.

Trait Implementations§

Source§

impl Debug for Server

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Server

§

impl !RefUnwindSafe for Server

§

impl !UnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnsafeUnpin 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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