Skip to main content

ServerHandle

Struct ServerHandle 

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

Cloneable command and management endpoint for a running Server.

The handle does not drive I/O itself: Server::run must remain active. Clones share call-ID allocation, retained media statistics, and the bounded command queue. Dropping the last handle closes that queue and lets the run loop perform its normal session shutdown.

Implementations§

Source§

impl ServerHandle

Source

pub fn set_call_answer_order(&self, order: CallSelectionOrder)

Applies to future answer requests that omit their call reference. Explicit references and existing session calls are not rewritten.

Source

pub fn latest_media_statistics( &self, device_id: &DeviceId, ) -> Option<MediaStatisticsSnapshot>

Return the latest fully correlated statistics response for a device.

Snapshots survive call and session teardown until a newer response for that device replaces them or the server is dropped.

Source

pub fn media_statistics(&self) -> Vec<(DeviceId, MediaStatisticsSnapshot)>

Clone every retained per-device snapshot, releasing the internal lock before a caller sorts, filters, or formats management output.

Source

pub async fn send(&self, command: Command) -> Result<(), ServerError>

Enqueue a station command, waiting for capacity in the server queue.

Success confirms queue admission only. The command may subsequently be discarded if the target session retired, and any station response is reported separately through Event. Use Self::send_confirmed when adapter resource lifetime depends on completion of the stream write.

Source

pub async fn send_confirmed(&self, command: Command) -> Result<(), ServerError>

Send a command and wait until its complete encoded frame has been written to the registered device’s TCP stream.

This is intentionally stronger than Self::send, whose completion only means the command entered the server queue. Lifecycle-sensitive callers use this boundary before releasing resources that protect the command’s on-device operation.

Source

pub fn try_send(&self, command: Command) -> Result<(), ServerError>

Enqueue a command without yielding, preserving the ordering of synchronous channel-driver callbacks such as call followed by hangup.

Source

pub async fn offer_incoming_call( &self, device_id: DeviceId, line_instance: LineInstance, info: CallInfo, ) -> Result<CallId, ServerError>

Allocate a call ID and enqueue an ordinarily ringing incoming offer.

The returned identity is stable across all later commands and handset events for the offer. A failed enqueue still consumes the reserved ID.

Source

pub fn reserve_call_id(&self) -> CallId

Reserve a call ID before exposing a call to a protocol session.

Channel-driver adapters use this to install all private channel state before the handset can answer the subsequent offer.

Source

pub async fn offer_incoming_call_with_id( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ) -> Result<(), ServerError>

Offer an incoming call using an ID previously returned by Self::reserve_call_id.

Source

pub async fn offer_incoming_call_with_id_and_ring( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, audible_ring: bool, ) -> Result<(), ServerError>

Source

pub async fn offer_incoming_call_with_id_and_ringer( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ringer: Option<IncomingRing>, ) -> Result<(), ServerError>

Enqueue an incoming offer with explicit audible presentation.

None creates a silent offer. Some applies the supplied ring mode and duration before selecting the incoming-call soft-key state.

Source

pub fn try_offer_incoming_call_with_id( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ) -> Result<(), ServerError>

Enqueue an incoming offer without yielding. Channel drivers should use this from their synchronous call callback so a following hangup cannot overtake the offer.

Source

pub fn try_offer_incoming_call_with_id_and_ring( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, audible_ring: bool, ) -> Result<(), ServerError>

Non-blocking form of Self::offer_incoming_call_with_id_and_ring.

Returns ServerError::CommandQueueFull without changing session state when immediate queue capacity is unavailable.

Source

pub fn try_offer_incoming_call_with_id_and_ringer( &self, device_id: DeviceId, line_instance: LineInstance, call_id: CallId, info: CallInfo, ringer: Option<IncomingRing>, ) -> Result<(), ServerError>

Source

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

Request orderly server shutdown.

Success means the request entered the queue. The owner must still await the Server::run future to know that it stopped accepting streams and issued disconnects to every registered session.

Source

pub async fn reconfigure( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, ) -> Result<ReconfigureResult, ServerError>

Atomically replace the configured station definitions. Only connected stations whose definition changed or was removed are asked to register again; unchanged live sessions and calls are preserved. Success means the replacement was committed and disconnect requests were queued, not that every affected transport has already closed.

Source

pub async fn reconfigure_affected( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, affected: impl IntoIterator<Item = DeviceId>, ) -> Result<ReconfigureResult, ServerError>

Atomically replaces station definitions and reconnects the explicit set in addition to stations whose wire definition changed. This lets a higher-level configuration owner apply line or global policy changes whose effects are not represented in DeviceDefinition.

Source

pub async fn reconfigure_station_policy( &self, definitions: impl IntoIterator<Item = DeviceDefinition>, affected: impl IntoIterator<Item = DeviceId>, anonymous_hotline: Option<AnonymousHotlineDefinition>, ) -> Result<ReconfigureResult, ServerError>

Commits station definitions and unknown-device admission as one server transaction before any affected session is disconnected.

Source

pub async fn reconfigure_anonymous_hotline( &self, definition: Option<AnonymousHotlineDefinition>, ) -> Result<usize, ServerError>

Replace the unknown-device guest template for future registrations. A changed policy disconnects only sessions that were admitted through the previous anonymous template; configured sessions are untouched. The returned count is the number of such sessions asked to disconnect.

Trait Implementations§

Source§

impl Clone for ServerHandle

Source§

fn clone(&self) -> ServerHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerHandle

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, <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<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