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§
Sourcefn sip_header_str(&self, name: &str) -> Option<&str>
fn sip_header_str(&self, name: &str) -> Option<&str>
Look up a SIP header by its canonical name (e.g. "Call-Info").
Provided Methods§
Sourcefn sip_header(&self, name: SipHeader) -> Option<&str>
fn sip_header(&self, name: SipHeader) -> Option<&str>
Look up a SIP header by its SipHeader enum variant.
Sourcefn sip_header_all_str<'a>(&'a self, name: &str) -> Vec<&'a str>
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.
Sourcefn sip_header_all(&self, name: SipHeader) -> Vec<&str>
fn sip_header_all(&self, name: SipHeader) -> Vec<&str>
Return all occurrences of a header by SipHeader variant.
Sourcefn call_info(&self) -> Result<Option<UriInfo>, UriInfoError>
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.
Sourcefn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError>
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.
Sourcefn p_asserted_identity(
&self,
) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
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.
Sourcefn p_preferred_identity(
&self,
) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn p_preferred_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse P-Preferred-Identity into a list of SipHeaderAddr (RFC 3325).
Sourcefn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse Route into a list of SipHeaderAddr (RFC 3261 §20.34).
Sourcefn record_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn record_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse Record-Route into a list of SipHeaderAddr (RFC 3261 §20.30).
Sourcefn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse Path into a list of SipHeaderAddr (RFC 3327).
Sourcefn service_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn service_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse Service-Route into a list of SipHeaderAddr (RFC 3608).
Sourcefn contact(&self) -> Result<Vec<ContactValue>, ParseSipHeaderAddrError>
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.
Sourcefn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError>
fn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError>
Parse Alert-Info into a UriInfo (RFC 3261 §20.4).
Sourcefn error_info(&self) -> Result<Option<UriInfo>, UriInfoError>
fn error_info(&self) -> Result<Option<UriInfo>, UriInfoError>
Parse Error-Info into a UriInfo (RFC 3261 §20.18).
Sourcefn supported(&self) -> Vec<&str>
fn supported(&self) -> Vec<&str>
Supported header values as individual option-tag tokens (RFC 3261 §20.37).
Sourcefn require_header(&self) -> Vec<&str>
fn require_header(&self) -> Vec<&str>
Require header values as individual option-tag tokens (RFC 3261 §20.32).
Sourcefn proxy_require(&self) -> Vec<&str>
fn proxy_require(&self) -> Vec<&str>
Proxy-Require values as individual option-tag tokens (RFC 3261 §20.29).
Sourcefn unsupported(&self) -> Vec<&str>
fn unsupported(&self) -> Vec<&str>
Unsupported values as individual option-tag tokens (RFC 3261 §20.40).
Sourcefn allow_events(&self) -> Vec<&str>
fn allow_events(&self) -> Vec<&str>
Allow-Events values as individual event-type tokens (RFC 6665).
Sourcefn content_encoding(&self) -> Vec<&str>
fn content_encoding(&self) -> Vec<&str>
Content-Encoding values as individual tokens (RFC 3261 §20.12).
Sourcefn content_language(&self) -> Vec<&str>
fn content_language(&self) -> Vec<&str>
Content-Language values as individual language tags (RFC 3261 §20.13).
Sourcefn in_reply_to(&self) -> Vec<&str>
fn in_reply_to(&self) -> Vec<&str>
In-Reply-To values as individual Call-ID tokens (RFC 3261 §20.21).
Sourcefn via(&self) -> Result<Option<SipVia>, SipViaError>
fn via(&self) -> Result<Option<SipVia>, SipViaError>
Parse Via into a SipVia (RFC 3261 §20.42).
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.
Parse Proxy-Authorization into a list of SipAuthValue (RFC 3261 §20.28).
Sourcefn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
fn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
Parse WWW-Authenticate into a list of SipAuthValue (RFC 3261 §20.44).
Sourcefn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
fn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
Parse Proxy-Authenticate into a list of SipAuthValue (RFC 3261 §20.27).
Sourcefn warning(&self) -> Result<Option<SipWarning>, SipWarningError>
fn warning(&self) -> Result<Option<SipWarning>, SipWarningError>
Parse Warning into a SipWarning (RFC 3261 §20.43).
Sourcefn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Parse Security-Client into a SipSecurity (RFC 3329).
Sourcefn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Parse Security-Server into a SipSecurity (RFC 3329).
Sourcefn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Parse Security-Verify into a SipSecurity (RFC 3329).
Sourcefn accept(&self) -> Result<Option<SipAccept>, SipAcceptError>
fn accept(&self) -> Result<Option<SipAccept>, SipAcceptError>
Parse Accept into a SipAccept (RFC 3261 §20.1).
Sourcefn accept_encoding(
&self,
) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError>
fn accept_encoding( &self, ) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError>
Parse Accept-Encoding into a SipAcceptEncoding (RFC 3261 §20.2).
Sourcefn accept_language(
&self,
) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError>
fn accept_language( &self, ) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError>
Parse Accept-Language into a SipAcceptLanguage (RFC 3261 §20.3).