#[non_exhaustive]pub struct SipHeaderAddr { /* private fields */ }Expand description
Parsed SIP name-addr (RFC 3261 §25.1) with header-level parameters.
The name-addr production from RFC 3261 §25.1 combines an optional
display name with a URI in angle brackets:
name-addr = [ display-name ] LAQUOT addr-spec RAQUOT
display-name = *(token LWS) / quoted-stringIn SIP headers (From, To, Contact, P-Asserted-Identity,
Refer-To), the name-addr is followed by header-level parameters
(RFC 3261 §20):
from-spec = ( name-addr / addr-spec ) *( SEMI from-param )
from-param = tag-param / generic-paramThis type handles the full production including those trailing
parameters (;tag=, ;expires=, ;serviceurn=, etc.).
Unlike sip_uri::NameAddr (which only handles the name-addr portion),
this type also parses header-level parameters after > and can
round-trip real SIP header values.
use sip_header::SipHeaderAddr;
let addr: SipHeaderAddr = r#""Alice" <sip:alice@example.com>;tag=abc123"#.parse().unwrap();
assert_eq!(addr.display_name(), Some("Alice"));
assert_eq!(addr.tag(), Some("abc123"));Display always emits angle brackets around the URI,
even for bare addr-spec input. This is the canonical form required by
RFC 3261 when header-level parameters are present.
Implementations§
Source§impl SipHeaderAddr
impl SipHeaderAddr
Sourcepub fn new(uri: Uri) -> SipHeaderAddr
pub fn new(uri: Uri) -> SipHeaderAddr
Create a new SipHeaderAddr with the given URI and no display name or params.
Sourcepub fn with_display_name(self, name: impl Into<String>) -> SipHeaderAddr
pub fn with_display_name(self, name: impl Into<String>) -> SipHeaderAddr
Set the display name.
Sourcepub fn with_param(
self,
key: impl Into<String>,
value: Option<impl Into<String>>,
) -> SipHeaderAddr
pub fn with_param( self, key: impl Into<String>, value: Option<impl Into<String>>, ) -> SipHeaderAddr
Add a header-level parameter. The key is lowercased on insertion.
Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
The display name, if present.
Sourcepub fn sip_uri(&self) -> Option<&SipUri>
pub fn sip_uri(&self) -> Option<&SipUri>
If the URI is a SIP/SIPS URI, return a reference to it.
Sourcepub fn params(&self) -> impl Iterator<Item = (&str, Option<&str>)>
pub fn params(&self) -> impl Iterator<Item = (&str, Option<&str>)>
Iterator over header-level parameters as (key, raw_value) pairs.
Keys are lowercased; values retain their original percent-encoding.
Sourcepub fn param(
&self,
name: &str,
) -> Option<Result<Option<Cow<'_, str>>, Utf8Error>>
pub fn param( &self, name: &str, ) -> Option<Result<Option<Cow<'_, str>>, Utf8Error>>
Look up a header-level parameter by name (case-insensitive).
Values are percent-decoded and validated as UTF-8. Returns Err if
the percent-decoded octets are not valid UTF-8. For non-UTF-8 values
or raw wire access, use param_raw().
Returns None if the param is not present, Some(Ok(None)) for
flag params (no value), Some(Ok(Some(decoded))) for valued params.
Trait Implementations§
Source§impl Clone for SipHeaderAddr
impl Clone for SipHeaderAddr
Source§fn clone(&self) -> SipHeaderAddr
fn clone(&self) -> SipHeaderAddr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SipHeaderAddr
impl Debug for SipHeaderAddr
Source§impl Display for SipHeaderAddr
impl Display for SipHeaderAddr
Source§impl FromStr for SipHeaderAddr
impl FromStr for SipHeaderAddr
Source§type Err = ParseSipHeaderAddrError
type Err = ParseSipHeaderAddrError
Source§fn from_str(
input: &str,
) -> Result<SipHeaderAddr, <SipHeaderAddr as FromStr>::Err>
fn from_str( input: &str, ) -> Result<SipHeaderAddr, <SipHeaderAddr as FromStr>::Err>
s to return a value of this type. Read moreSource§impl PartialEq for SipHeaderAddr
impl PartialEq for SipHeaderAddr
impl Eq for SipHeaderAddr
impl StructuralPartialEq for SipHeaderAddr
Auto Trait Implementations§
impl Freeze for SipHeaderAddr
impl RefUnwindSafe for SipHeaderAddr
impl Send for SipHeaderAddr
impl Sync for SipHeaderAddr
impl Unpin for SipHeaderAddr
impl UnsafeUnpin for SipHeaderAddr
impl UnwindSafe for SipHeaderAddr
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.