Skip to main content

Negotiation

Struct Negotiation 

Source
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

Source

pub const fn idle() -> Self

Nothing outstanding in either direction.

Source

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.

Source

pub const fn offering() -> Self

The state of a UAC that has just sent an INVITE carrying an offer.

Source

pub const fn owing() -> Self

The state of a UAS that has just received an INVITE carrying an offer.

Source

pub const fn is_offering(self) -> bool

Whether an offer of ours is unanswered.

Source

pub const fn owes_answer(self) -> bool

Whether we owe the peer an answer.

Source

pub const fn sent_offer(&mut self)

Record that we put an offer on the wire.

Source

pub const fn received_answer(&mut self)

Record that the answer to our offer arrived.

Source

pub const fn received_offer(&mut self)

Record that an offer arrived and is unanswered.

Source

pub const fn sent_answer(&mut self)

Record that we answered the offer we were holding.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Negotiation

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 Negotiation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Negotiation

Source§

fn default() -> Negotiation

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Negotiation

Source§

fn eq(&self, other: &Negotiation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Negotiation

Source§

impl Eq for Negotiation

Source§

impl StructuralPartialEq for Negotiation

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.

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> 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.