Skip to main content

Dispatcher

Struct Dispatcher 

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

One endpoint’s incoming requests, routed to any number of concurrent calls.

Owns the endpoint’s Receiver<Incoming>, which is the whole reason it can promise anything: there is exactly one of those, so anything else reading it would be reading requests this cannot then route.

Implementations§

Source§

impl Dispatcher

Source

pub fn new(endpoint: Handle, incoming: Receiver<Incoming>) -> Self

Take over an endpoint’s incoming requests, with the default per-call queue depth.

Source

pub fn with_queue( endpoint: Handle, incoming: Receiver<Incoming>, queue: usize, ) -> Self

The same, with a per-call queue depth of your own.

A depth of zero is raised to one: an unbuffered channel would shed every request that arrived while the call was between recv calls, which is most of them.

Source

pub fn with_identity(self, identity: InboundIdentityPolicy) -> Self

Verify new inbound INVITEs before they become answerable application invitations.

A verification failure is sent on the INVITE transaction with its RFC 8224 status and the request is not surfaced. With no selected policy, dispatch remains wire-compatible and performs no credential acquisition or time read.

Source

pub fn with_notifier(self, notifier: Notifier) -> Self

Serve inbound RFC 6665 SUBSCRIBE requests through this bounded notifier.

Source

pub fn with_event_subscriptions(self, subscriptions: EventSubscriptions) -> Self

Route inbound NOTIFY requests to a bounded outbound event-subscription client.

Source

pub fn with_publications(self, publications: Publications) -> Self

Serve inbound PUBLISH and attach outbound publication transactions to this endpoint.

Source

pub fn calls(&self) -> Calls

A handle for registering calls this dispatcher did not itself surface.

Source

pub fn register(&self, dialog: &Dialog) -> Receiver<Incoming>

Route this dialog’s requests to the returned inbox — Calls::register, for an application that holds the dispatcher directly.

Source

pub fn counts(&self) -> DispatchCounts

What has been refused, shed or left unplaced.

Source

pub fn begin_drain(&mut self)

Atomically close new-dialog admission for this dispatcher and its transport endpoint.

Existing routes and transactions remain live. Calling this more than once is harmless.

Source

pub const fn is_draining(&self) -> bool

Whether new-dialog admission has been closed.

Source

pub async fn drain_progress(&self) -> Result<DrainProgress>

Observe the two completion dimensions used by Self::drain.

Source

pub async fn drain(&mut self, within: Duration) -> Result<DrainReport>

Close admission, drive existing dialogs and transactions, and stop the endpoint.

Completion is event-driven: route receiver closure and the endpoint’s transaction-terminal barrier. within only bounds failure. At expiry every remaining route is closed, the live counts are logged and returned, and the ordinary endpoint shutdown path cancels and joins transport-owned tasks.

Source

pub async fn next(&mut self) -> Option<Dispatched>

The next thing the dispatcher cannot place itself.

Routes everything else on the way, so this must be called in a loop for a dispatcher to do its job at all — the ACKs and BYEs of every call it has already handed out move only while it is being polled. None once the endpoint has shut down.

Trait Implementations§

Source§

impl Debug for Dispatcher

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,