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: RoleWhich side we are.
id: DialogIdWhat identifies it.
local_uri: StringOur address of record.
remote_uri: StringTheirs.
remote_target: UriWhere to send in-dialog requests, from their Contact.
local_cseq: u32Our 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
impl Dialog
Sourcepub fn from_response(request: &Request, response: &Response) -> Option<Self>
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.
Sourcepub fn from_request(request: &Request, local_tag: &str) -> Option<Self>
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.
Sourcepub fn local_and_remote(&self) -> (String, String)
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.
Sourcepub fn first_route(&self) -> Option<Uri>
pub fn first_route(&self) -> Option<Uri>
The first entry of the route set, as a URI.
Sourcepub fn hop(&self) -> Uri
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.
Sourcepub fn request_target(&self) -> (Uri, Vec<String>)
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.
Sourcepub fn refresh_target(&mut self, headers: &Headers)
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.
Sourcepub fn is_out_of_order(&self, request: &Request) -> bool
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.
Sourcepub fn record_remote_cseq(&mut self, request: &Request)
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.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Dialog
impl RefUnwindSafe for Dialog
impl Send for Dialog
impl Sync for Dialog
impl Unpin for Dialog
impl UnsafeUnpin for Dialog
impl UnwindSafe for Dialog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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