Skip to main content

TransactionKey

Enum TransactionKey 

Source
pub enum TransactionKey {
    Rfc3261 {
        branch: Vec<u8>,
        sent_by: Vec<u8>,
        method: Vec<u8>,
    },
    Legacy {
        request_uri: Vec<u8>,
        top_via: Vec<u8>,
        from_tag: Vec<u8>,
        to_tag: Vec<u8>,
        call_id: Vec<u8>,
        cseq: u32,
        method: Vec<u8>,
    },
}
Expand description

A key identifying a transaction.

Variants§

§

Rfc3261

RFC 3261 matching: the branch carries the magic cookie.

Fields

§branch: Vec<u8>

The branch parameter of the topmost Via.

§sent_by: Vec<u8>

The topmost Via’s sent-by, lowercased.

§method: Vec<u8>

The method, with ACK folded to INVITE.

§

Legacy

RFC 2543 matching, reconstructed from the fields that were available before branch meant anything.

Fields

§request_uri: Vec<u8>

The Request-URI, for a request; empty for a response.

§top_via: Vec<u8>

The topmost Via, verbatim.

§from_tag: Vec<u8>

The From tag.

§to_tag: Vec<u8>

The To tag, which RFC 3261 §17.2.3 makes part of the match: a forked INVITE retried under a different tag, and an ACK belonging to another branch’s response, are separate transactions however alike the rest of their fields look.

§call_id: Vec<u8>

The Call-ID.

§cseq: u32

The CSeq number.

§method: Vec<u8>

The method, with ACK folded to INVITE.

Implementations§

Source§

impl TransactionKey

Source

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

The key a received request belongs to (RFC 3261 §17.2.3).

Returns None if the request has no usable Via, which is not a transaction question — a request without a Via cannot be answered at all, and validation reports it.

Source

pub fn from_sent_request(request: &Request) -> Option<Self>

The key a request sent by this element belongs to (RFC 3261 §17.1.3).

Not Self::from_request’s derivation. §17.2.3 is the server rule, and it keys a legacy transaction on the Request-URI and the To tag; a response has no Request-URI at all, and carries the tag the UAS added rather than the one the request was sent with. A client keyed by the server rule therefore never matches any of its own responses — it does not fail, it retransmits until Timer F with the answer sitting in front of it.

§17.1.3 is narrower on purpose (docs/specs/sip-transaction.md §6.2): the key is the branch and the CSeq method, over fields a response echoes back unchanged. This agrees with Self::from_response field for field, which is the property that matters.

The legacy half of this is reached by an application that supplies its own cookieless Via, not by an old peer: the topmost Via on a client transaction is ours, and the transport gives it a z9hG4bK branch. Self::from_request is the one old peers meet.

Source

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

The key a received response belongs to (RFC 3261 §17.1.3).

The branch of the topmost Via plus the CSeq method — and only those two. In particular the sent-by is not part of it, because the response may come back from a different address than the request went to.

Source

pub fn for_cancelled_invite(request: &Request) -> Option<Self>

The key of the INVITE a CANCEL refers to (RFC 3261 §9.2).

A CANCEL shares the INVITE’s branch and differs only in method, so this is that key with the method put back. Returns None for anything that is not a CANCEL, since no other request cancels one.

Source

pub fn is_legacy(&self) -> bool

Whether this key was derived by the pre-RFC-3261 rules.

Trait Implementations§

Source§

impl Clone for TransactionKey

Source§

fn clone(&self) -> TransactionKey

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 TransactionKey

Source§

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

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

impl Hash for TransactionKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TransactionKey

Source§

fn eq(&self, other: &TransactionKey) -> 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 Eq for TransactionKey

Source§

impl StructuralPartialEq for TransactionKey

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.