Skip to main content

Via

Struct Via 

Source
pub struct Via {
    pub protocol: Vec<u8>,
    pub version: Vec<u8>,
    pub transport: Vec<u8>,
    pub host: Host,
    pub port: Option<u16>,
    pub params: Vec<HeaderParam>,
}
Expand description

One Via value.

Fields§

§protocol: Vec<u8>

The protocol name, normally SIP.

§version: Vec<u8>

The protocol version, normally 2.0.

§transport: Vec<u8>

The transport: UDP, TCP, TLS, SCTP, WS, WSS, or anything else a peer sends — RFC 4475 §3.1.1.10 requires unknown transports to parse.

§host: Host

The host this hop wants responses sent to.

§port: Option<u16>

The port, if stated.

§params: Vec<HeaderParam>

The via parameters.

Implementations§

Source§

impl Via

Source

pub fn overload(&self) -> Result<ViaOverload, HeaderError>

Decode the RFC 7339/RFC 7415 overload-control parameters on this hop.

Presence and value of oc stay distinct because the client sends the former and only a server may send the latter. Invalid numbers are errors rather than zero: zero has protocol meaning for both loss/rate and validity.

Source

pub fn branch(&self) -> Option<&[u8]>

The branch parameter, which identifies the transaction.

Source

pub fn has_rfc3261_branch(&self) -> bool

Whether the branch carries the RFC 3261 magic cookie.

When it does not, the sender predates RFC 3261 and transaction matching must fall back to the rules in §17.2.3.

Source

pub fn received(&self) -> Option<&[u8]>

The received parameter: the source address the previous hop was actually seen from (RFC 3261 §18.2.1).

Source

pub fn rport(&self) -> Option<Option<&[u8]>>

The rport parameter (RFC 3581). Present with no value in a request means “tell me what port you saw”; present with a value in a response is that port.

Source

pub fn maddr(&self) -> Option<&[u8]>

The maddr parameter.

Source

pub fn ttl(&self) -> Option<&[u8]>

The ttl parameter.

Source

pub fn param(&self, name: &str) -> Option<&[u8]>

Any via parameter, by name.

Source

pub fn parse_one(value: &[u8]) -> Result<Self, HeaderError>

Parse one Via value — a single hop, not a comma-separated list.

Source

pub fn parse_list(value: &[u8]) -> Result<Vec<Self>, HeaderError>

Parse a header value that may carry several comma-separated hops.

Trait Implementations§

Source§

impl Clone for Via

Source§

fn clone(&self) -> Via

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 Via

Source§

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

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

impl TypedHeader for Via

Source§

fn decode(value: &[u8]) -> Result<Self, HeaderError>

Decodes the first hop in the value.

A single Via header line may carry several comma-separated hops, so typed::<Via>() gives the topmost one — which is the one that matters for routing a response. Use Via::parse_list when every hop is needed.

Source§

const NAME: HeaderName = HeaderName::Via

The header this type reads.
Source§

fn decode_list(value: &[u8]) -> Result<Vec<Self>, HeaderError>

Parse every value in one header row. Read more
Source§

const VALIDATE_LIST: bool = false

Whether Headers::typed_all must collect and validate the complete field before yielding. Read more
Source§

fn validate_list(_values: &[&Self]) -> Result<(), HeaderError>

Validate all decoded values of this field across the complete message. Read more

Auto Trait Implementations§

§

impl !Freeze for Via

§

impl RefUnwindSafe for Via

§

impl Send for Via

§

impl Sync for Via

§

impl Unpin for Via

§

impl UnsafeUnpin for Via

§

impl UnwindSafe for Via

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.