Skip to main content

Dialog

Struct Dialog 

Source
pub struct Dialog {
    pub role: Role,
    pub id: DialogId,
    pub local_uri: String,
    pub remote_uri: String,
    pub remote_target: Uri,
    pub local_cseq: u32,
    pub remote_cseq: Option<u32>,
    pub route_set: Vec<String>,
}
Expand description

A dialog.

Fields§

§role: Role

Which side we are.

§id: DialogId

What identifies it.

§local_uri: String

Our address of record.

§remote_uri: String

Theirs.

§remote_target: Uri

Where to send in-dialog requests, from their Contact.

§local_cseq: u32

Our sequence number for requests we originate. Independent of theirs.

§remote_cseq: Option<u32>

The highest sequence number we have seen from them.

§route_set: Vec<String>

The route set, already in send order.

Implementations§

Source§

impl Dialog

Source

pub fn from_response(request: &Request, response: &Response) -> Option<Self>

Build the caller’s half from the request it sent and the response it got.

Returns None if the response carries no To tag, which means no dialog was created — a 100 Trying, for instance.

Source

pub fn from_request(request: &Request, local_tag: &str) -> Option<Self>

Build the callee’s half from the request that created it and the tag we chose.

Source

pub fn local_and_remote(&self) -> (String, String)

The To and From for a request we originate.

They swap according to role, which is the detail a UAS most often gets wrong: a BYE from the callee has the callee in From, not in To.

Source

pub fn next_cseq(&mut self) -> u32

Take the next sequence number for a request we originate.

Source

pub fn first_route(&self) -> Option<Uri>

The first entry of the route set, as a URI.

Source

pub fn hop(&self) -> Uri

Where an in-dialog request is sent, which is not always what its Request-URI says.

RFC 3261 §12.2.1.1: with a route set the request goes to the first Route entry — the proxy that record-routed itself into the dialog precisely so that it would see the rest of it. Handing the request to the remote target instead bypasses that proxy, and where it is the only element that can reach the far end — behind a NAT, or on a segment this side cannot address — the request is simply lost. A BYE lost this way is the call that cannot be hung up, with the media still running.

Source

pub fn request_target(&self) -> (Uri, Vec<String>)

The Request-URI and Route headers for a request sent inside this dialog.

RFC 3261 §12.2.1.1 describes two forms, chosen by the lr parameter on the first route. A loose router leaves the Request-URI alone: the remote target addresses the request and the route set travels in Route headers, in order. A strict router predates that convention and rewrites the Request-URI at every hop, so the first route becomes the Request-URI and the remote target moves to the end of the route set — otherwise the far end receives a request addressed to a proxy it has never heard of.

Source

pub fn refresh_target(&mut self, headers: &Headers)

Replace the remote target from a target refresh request or its response.

RFC 3261 §12.2.2 and §12.2.1.2: a re-INVITE carrying a Contact moves the dialog’s remote target, in both directions. Keeping the original means every later request goes to where the peer used to be — the BYE included, so a peer that re-homes mid-call can never be told the call is over.

Source

pub fn is_out_of_order(&self, request: &Request) -> bool

Whether an in-dialog request arrived out of order (RFC 3261 §12.2.2).

§12.2.2 rejects a request behind the dialog’s sequence number with a 500 rather than applying it, and §12.2.1.1 requires each new in-dialog request to increment the number — so a repeat of the current one is a duplicate that has escaped the transaction layer’s absorption window, not a fresh request, and is refused on the same grounds.

The rule lives here, on the dialog, because every in-dialog path needs it and each one that carries its own copy is a way around it. That is not hypothetical: the early dialog’s UPDATE handler was written without it, and a replayed BYE arriving afterwards ended a call that was still running — the exact failure the guard on the confirmed path was put there to stop.

Source

pub fn record_remote_cseq(&mut self, request: &Request)

Record the sequence number of an in-dialog request accepted here (RFC 3261 §12.2.2).

Only ever forwards. A lower number never reaches this — Self::is_out_of_order has refused it — but the max makes that a property of this function rather than of every caller remembering to ask first.

Source

pub fn matches(&self, request: &Request) -> bool

Whether an in-dialog request belongs to this dialog.

Trait Implementations§

Source§

impl Clone for Dialog

Source§

fn clone(&self) -> Dialog

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 Dialog

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.

§

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