pub struct Negotiation { /* private fields */ }Expand description
One dialog’s offer/answer bookkeeping, as far as UPDATE is concerned (RFC 3264, RFC 3311 §5).
Three pieces of state, and the reason they are three rather than one is §5.2: a dialog that owes an answer and a dialog whose own offer is unanswered are different situations that produce different refusals, and an UPDATE already being processed is a third that has nothing to do with descriptions at all.
Implementations§
Source§impl Negotiation
impl Negotiation
Sourcepub const fn is_idle(self) -> bool
pub const fn is_idle(self) -> bool
Whether no offer, answer, or accepted UPDATE remains outstanding.
This is stricter than Self::may_offer: an offerless UPDATE in progress creates no
offer debt, but it is still a live transaction and therefore cannot cross a durable
dialog boundary.
Sourcepub const fn offering() -> Self
pub const fn offering() -> Self
The state of a UAC that has just sent an INVITE carrying an offer.
Sourcepub const fn owing() -> Self
pub const fn owing() -> Self
The state of a UAS that has just received an INVITE carrying an offer.
Sourcepub const fn is_offering(self) -> bool
pub const fn is_offering(self) -> bool
Whether an offer of ours is unanswered.
Sourcepub const fn owes_answer(self) -> bool
pub const fn owes_answer(self) -> bool
Whether we owe the peer an answer.
Sourcepub const fn sent_offer(&mut self)
pub const fn sent_offer(&mut self)
Record that we put an offer on the wire.
Sourcepub const fn received_answer(&mut self)
pub const fn received_answer(&mut self)
Record that the answer to our offer arrived.
Sourcepub const fn received_offer(&mut self)
pub const fn received_offer(&mut self)
Record that an offer arrived and is unanswered.
Sourcepub const fn sent_answer(&mut self)
pub const fn sent_answer(&mut self)
Record that we answered the offer we were holding.
Sourcepub const fn may_offer(self) -> bool
pub const fn may_offer(self) -> bool
Whether an UPDATE this side sends may carry an offer (RFC 3311 §5.1).
RFC 3264’s one-offer-at-a-time rule, seen from the sending end: not while ours is
unanswered, and not while we owe one. in_progress does not appear — that is the
peer’s transaction, and an offer of ours is unrelated to it.
Sourcepub const fn receive(&mut self, has_offer: bool) -> Reception
pub const fn receive(&mut self, has_offer: bool) -> Reception
Decide what to do with an incoming UPDATE (RFC 3311 §5.2), and record the decision.
The order is normative rather than incidental: the in-progress rule is checked first because it applies to every UPDATE, including one with no body, and answering a second UPDATE 491 because the first one’s offer is still open would tell the peer it collided with us when what actually happened is that it was early.
A refusal changes nothing. It is itself a final response, so there is no transaction left in progress and no description has moved.
Sourcepub const fn answered(&mut self)
pub const fn answered(&mut self)
Record that the final response to the accepted UPDATE has gone out.
Clears only the debt that UPDATE created. When it carried an offer the 2xx carried the answer (§5.2: the UAS “MUST … generate an answer in the 2xx response”) and the debt is paid; when it carried none — the RFC 4028 §7.4 refresh, which is the most ordinary UPDATE a peer sends — it created no debt and pays none.
Clearing owed regardless was a real defect and not a tidiness point. An offerless
refresh arriving in an early dialog would wipe the INVITE’s outstanding offer, and the
next UPDATE carrying one would then be accepted and answered 488 for a description
that was perfectly good — where §5.2 rule 3 requires 500 with Retry-After, which is
the difference between “your description is unusable” and “you are early”.
Calling this with nothing in progress is a no-op, so a caller that clears on an error path cannot destroy state it did not create.
Trait Implementations§
Source§impl Clone for Negotiation
impl Clone for Negotiation
Source§fn clone(&self) -> Negotiation
fn clone(&self) -> Negotiation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Negotiation
impl Debug for Negotiation
Source§impl Default for Negotiation
impl Default for Negotiation
Source§fn default() -> Negotiation
fn default() -> Negotiation
Source§impl PartialEq for Negotiation
impl PartialEq for Negotiation
Source§fn eq(&self, other: &Negotiation) -> bool
fn eq(&self, other: &Negotiation) -> bool
self and other values to be equal, and is used by ==.