Skip to main content

Invitation

Struct Invitation 

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

An incoming call: the INVITE, and the inbox of the call it may become.

The inbox exists before the application has decided anything, and that is the point. The ACK to our own 2xx can arrive before answer has returned, so a route installed only once a Call existed would have nowhere to put it.

Dropping this without answering releases the route: the next request for that dialog is answered as an unknown one rather than queued for a call that will never exist.

It is also what a CANCEL for this INVITE ends (RFC 3261 §9.2). The dispatcher answers the CANCEL itself — is_cancelled and events are how an application finds out, and answer is how it is stopped from accepting an invitation the caller has already withdrawn.

Implementations§

Source§

impl Invitation

Source

pub fn request(&self) -> &Incoming

The INVITE, to answer, ring or refuse.

Source

pub fn is_cancelled(&self) -> bool

Whether the caller withdrew this invitation before it was answered (RFC 3261 §9.2).

True from the moment the dispatcher has answered a matching CANCEL, which is also the moment it sent the 487 that ended the INVITE transaction. There is nothing left to accept: Self::answer refuses with Error::InvitationCancelled from here on.

This is the poll. Self::events is the push, and an application that is ringing wants that one — it has to be told to stop, not remember to ask.

Source

pub fn events(&mut self) -> Option<CallEvents>

This invitation’s event stream, handed out exactly once.

Returns None on every call after the first, the same contract Call::events has and for the same reason: there is one consumer by construction rather than a value a second reader could be cloned from.

Exactly one event is ever emitted on it — CallEvent::Ended(EndCause::RemoteCancel), when the caller gives up. An invitation that is answered produces no event here: it becomes a Call, which has a stream of its own that starts with Answered.

Source

pub async fn answer( &self, endpoint: &Handle, media_address: IpAddr, ) -> Result<Call>

Answer this invitation, unless the caller has already withdrawn it.

crate::answer with two things the free function cannot know, both of which come from the invitation owning the INVITE’s server transaction:

  • It fails with Error::InvitationCancelled once a CANCEL has ended the transaction, rather than putting a 200 on a transaction that already carried a 487.
  • It records that a final response has gone out, which is what makes a CANCEL arriving afterwards the no-op RFC 3261 §9.2 requires instead of a teardown.

The To tag is the invitation’s own, so the 200 accepting it and the 200 answering a late CANCEL agree on one, which is §9.2’s SHOULD.

Prefer this to crate::answer on anything a Dispatcher surfaced. The free function still works and still answers correctly — it simply cannot tell the dispatcher what it did, so a CANCEL that arrives around it is judged on the transaction’s last known state.

Answers from the default codec set, Codecs::G711. Self::answer_with takes a selection.

Source

pub async fn answer_with( &self, endpoint: &Handle, media_address: IpAddr, codecs: Codecs, ) -> Result<Call>

Self::answer, from a chosen codec set rather than the default one (M-30).

The dispatcher’s counterpart of crate::answer_with. This exists rather than being left to the free function because this is the path the docs above tell an application to prefer: a selection reachable only through crate::answer_with would be a selection every dispatched call has to give up cancellation bookkeeping to make.

Source

pub async fn answer_with_policy( &self, endpoint: &Handle, media_address: IpAddr, policy: MediaPolicy, ) -> Result<Call>

Self::answer, using one coherent codec and ICE policy.

Source

pub async fn answer_with_policy_at( &self, endpoint: &Handle, media_address: MediaAddress, policy: MediaPolicy, ) -> Result<Call>

Self::answer_with_policy with independent advertised and bound media addresses.

Source

pub async fn trying(&self, endpoint: &Handle) -> Result<()>

Send the optional 100 Trying used by a signalling workload.

A 100 creates neither an early dialog nor a final-response claim, so a matching CANCEL may still end this invitation afterwards. It deliberately carries no To tag (RFC 3261 §8.2.6.2).

Source

pub async fn answer_signalling( self, endpoint: &Handle, contact: impl Into<Bytes>, ) -> Result<SignallingCall>

Accept an SDP-free INVITE as a signalling-only confirmed dialog.

No media socket or task is created. The returned SignallingCall owns the reserved per-dialog inbox, retransmits this 2xx until a valid ACK, validates BYE, and can originate a bounded BYE of its own. contact is the local dialog target advertised in the final response.

Source

pub async fn answer_signalling_with_tag( self, endpoint: &Handle, contact: impl Into<Bytes>, tag: impl Into<String>, ) -> Result<SignallingCall>

Self::answer_signalling with an application-selected, validated dialog tag.

This exists for deterministic protocol fixtures. The tag is claimed atomically with the invitation, so a crossing CANCEL either wins with the old pending tag or loses and uses this same tag in its own response; the two transactions cannot disagree.

Source

pub async fn refuse( &self, endpoint: &Handle, status: u16, reason: impl Into<Bytes>, ) -> Result<()>

Refuse this pending invitation with a final response.

The dispatcher’s cancellation state is claimed before the response leaves, so a crossing CANCEL receives its own 200 but cannot also replace this final response with 487.

Source

pub fn into_parts(self) -> (Incoming, Receiver<Incoming>)

Split into the INVITE and the inbox, ready for answer and serve.

What is given up is the cancellation state: Self::is_cancelled and Self::answer go with it. The dispatcher keeps answering CANCELs for this transaction either way — the table owns that, not this handle — so what is lost is the application’s view of it, which is why this is the call to make after answering rather than instead of it.

Trait Implementations§

Source§

impl Debug for Invitation

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,