Skip to main content

SipHeaderLookup

Trait SipHeaderLookup 

Source
pub trait SipHeaderLookup {
Show 36 methods // Required method fn sip_header_str(&self, name: &str) -> Option<&str>; // Provided methods fn sip_header(&self, name: SipHeader) -> Option<&str> { ... } fn sip_header_all_str<'a>(&'a self, name: &str) -> Vec<&'a str> { ... } fn sip_header_all(&self, name: SipHeader) -> Vec<&str> { ... } fn call_info(&self) -> Result<Option<UriInfo>, UriInfoError> { ... } fn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError> { ... } fn p_asserted_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn p_preferred_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn record_route( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn service_route( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError> { ... } fn contact(&self) -> Result<Vec<ContactValue>, ParseSipHeaderAddrError> { ... } fn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError> { ... } fn error_info(&self) -> Result<Option<UriInfo>, UriInfoError> { ... } fn allow(&self) -> Vec<&str> { ... } fn supported(&self) -> Vec<&str> { ... } fn require_header(&self) -> Vec<&str> { ... } fn proxy_require(&self) -> Vec<&str> { ... } fn unsupported(&self) -> Vec<&str> { ... } fn allow_events(&self) -> Vec<&str> { ... } fn content_encoding(&self) -> Vec<&str> { ... } fn content_language(&self) -> Vec<&str> { ... } fn in_reply_to(&self) -> Vec<&str> { ... } fn via(&self) -> Result<Option<SipVia>, SipViaError> { ... } fn authorization(&self) -> Result<Vec<SipAuthValue>, SipAuthError> { ... } fn proxy_authorization(&self) -> Result<Vec<SipAuthValue>, SipAuthError> { ... } fn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError> { ... } fn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError> { ... } fn warning(&self) -> Result<Option<SipWarning>, SipWarningError> { ... } fn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError> { ... } fn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError> { ... } fn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError> { ... } fn accept(&self) -> Result<Option<SipAccept>, SipAcceptError> { ... } fn accept_encoding( &self, ) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError> { ... } fn accept_language( &self, ) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError> { ... }
}
Expand description

Trait for looking up standard SIP headers from any key-value store.

Implementors provide sip_header_str() and get all typed accessors as default implementations.

§Example

use std::collections::HashMap;
use sip_header::{SipHeaderLookup, SipHeader};

let mut headers = HashMap::new();
headers.insert(
    "Call-Info".to_string(),
    "<urn:emergency:uid:callid:abc>;purpose=emergency-CallId".to_string(),
);

assert_eq!(
    headers.sip_header(SipHeader::CallInfo),
    Some("<urn:emergency:uid:callid:abc>;purpose=emergency-CallId"),
);

let ci = headers.call_info().unwrap().unwrap();
assert_eq!(ci.entries()[0].purpose(), Some("emergency-CallId"));

Required Methods§

Source

fn sip_header_str(&self, name: &str) -> Option<&str>

Look up a SIP header by its canonical name (e.g. "Call-Info").

Provided Methods§

Source

fn sip_header(&self, name: SipHeader) -> Option<&str>

Look up a SIP header by its SipHeader enum variant.

Source

fn sip_header_all_str<'a>(&'a self, name: &str) -> Vec<&'a str>

Return all occurrences of a header by canonical name.

Unlike sip_header_str which returns at most one value, this method returns every occurrence. The default implementation wraps sip_header_str in a single-element Vec; storage backends that preserve per-occurrence values (e.g. HashMap<String, Vec<String>>) should override this.

Source

fn sip_header_all(&self, name: SipHeader) -> Vec<&str>

Return all occurrences of a header by SipHeader variant.

Source

fn call_info(&self) -> Result<Option<UriInfo>, UriInfoError>

Parse the Call-Info header into a UriInfo.

Returns Ok(None) if the header is absent, Err if present but unparseable.

Source

fn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError>

Parse the History-Info header into a HistoryInfo.

Returns Ok(None) if the header is absent, Err if present but unparseable.

Source

fn p_asserted_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse P-Asserted-Identity into a list of SipHeaderAddr.

PAI is multi-valued per RFC 3325 — a message may assert up to two identities. Returns an empty Vec if the header is absent.

Source

fn p_preferred_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse P-Preferred-Identity into a list of SipHeaderAddr (RFC 3325).

Source

fn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse Route into a list of SipHeaderAddr (RFC 3261 §20.34).

Source

fn record_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse Record-Route into a list of SipHeaderAddr (RFC 3261 §20.30).

Source

fn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse Path into a list of SipHeaderAddr (RFC 3327).

Source

fn service_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>

Parse Service-Route into a list of SipHeaderAddr (RFC 3608).

Source

fn contact(&self) -> Result<Vec<ContactValue>, ParseSipHeaderAddrError>

Parse Contact into a list of ContactValue (RFC 3261 §20.10).

The Contact header may contain * (wildcard, used in REGISTER) or a comma-separated list of name-addr/addr-spec entries.

Source

fn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError>

Parse Alert-Info into a UriInfo (RFC 3261 §20.4).

Source

fn error_info(&self) -> Result<Option<UriInfo>, UriInfoError>

Parse Error-Info into a UriInfo (RFC 3261 §20.18).

Source

fn allow(&self) -> Vec<&str>

Allow header values as individual method tokens (RFC 3261 §20.5).

Source

fn supported(&self) -> Vec<&str>

Supported header values as individual option-tag tokens (RFC 3261 §20.37).

Source

fn require_header(&self) -> Vec<&str>

Require header values as individual option-tag tokens (RFC 3261 §20.32).

Source

fn proxy_require(&self) -> Vec<&str>

Proxy-Require values as individual option-tag tokens (RFC 3261 §20.29).

Source

fn unsupported(&self) -> Vec<&str>

Unsupported values as individual option-tag tokens (RFC 3261 §20.40).

Source

fn allow_events(&self) -> Vec<&str>

Allow-Events values as individual event-type tokens (RFC 6665).

Source

fn content_encoding(&self) -> Vec<&str>

Content-Encoding values as individual tokens (RFC 3261 §20.12).

Source

fn content_language(&self) -> Vec<&str>

Content-Language values as individual language tags (RFC 3261 §20.13).

Source

fn in_reply_to(&self) -> Vec<&str>

In-Reply-To values as individual Call-ID tokens (RFC 3261 §20.21).

Source

fn via(&self) -> Result<Option<SipVia>, SipViaError>

Parse Via into a SipVia (RFC 3261 §20.42).

Source

fn authorization(&self) -> Result<Vec<SipAuthValue>, SipAuthError>

Parse Authorization into a list of SipAuthValue (RFC 3261 §20.7).

Auth headers MUST NOT be comma-combined (RFC 3261 §7.3.1), so each occurrence is parsed separately via sip_header_all.

Source

fn proxy_authorization(&self) -> Result<Vec<SipAuthValue>, SipAuthError>

Parse Proxy-Authorization into a list of SipAuthValue (RFC 3261 §20.28).

Source

fn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>

Parse WWW-Authenticate into a list of SipAuthValue (RFC 3261 §20.44).

Source

fn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>

Parse Proxy-Authenticate into a list of SipAuthValue (RFC 3261 §20.27).

Source

fn warning(&self) -> Result<Option<SipWarning>, SipWarningError>

Parse Warning into a SipWarning (RFC 3261 §20.43).

Source

fn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError>

Parse Security-Client into a SipSecurity (RFC 3329).

Source

fn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError>

Parse Security-Server into a SipSecurity (RFC 3329).

Source

fn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError>

Parse Security-Verify into a SipSecurity (RFC 3329).

Source

fn accept(&self) -> Result<Option<SipAccept>, SipAcceptError>

Parse Accept into a SipAccept (RFC 3261 §20.1).

Source

fn accept_encoding( &self, ) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError>

Parse Accept-Encoding into a SipAcceptEncoding (RFC 3261 §20.2).

Source

fn accept_language( &self, ) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError>

Parse Accept-Language into a SipAcceptLanguage (RFC 3261 §20.3).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SipHeaderLookup for HashMap<String, String>

Source§

fn sip_header_str(&self, name: &str) -> Option<&str>

Source§

impl SipHeaderLookup for HashMap<String, Vec<String>>

Source§

fn sip_header_str(&self, name: &str) -> Option<&str>

Source§

fn sip_header_all_str(&self, name: &str) -> Vec<&str>

Implementors§