pub trait SipHeaderLookup {
// Required method
fn sip_header_str(&self, name: &str) -> Option<&str>;
// Provided methods
fn sip_header(&self, name: SipHeader) -> Option<&str> { ... }
fn call_info_raw(&self) -> Option<&str> { ... }
fn call_info(&self) -> Result<Option<SipCallInfo>, SipCallInfoError> { ... }
fn history_info_raw(&self) -> Option<&str> { ... }
fn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError> { ... }
fn p_asserted_identity_raw(&self) -> Option<&str> { ... }
fn p_asserted_identity(
&self,
) -> Result<Option<SipHeaderAddr>, ParseSipHeaderAddrError> { ... }
}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 call_info_raw(&self) -> Option<&str>
fn call_info_raw(&self) -> Option<&str>
Raw Call-Info header value (RFC 3261 section 20.9).
Sourcefn call_info(&self) -> Result<Option<SipCallInfo>, SipCallInfoError>
fn call_info(&self) -> Result<Option<SipCallInfo>, SipCallInfoError>
Parse the Call-Info header into a SipCallInfo.
Returns Ok(None) if the header is absent, Err if present but unparseable.
Sourcefn history_info_raw(&self) -> Option<&str>
fn history_info_raw(&self) -> Option<&str>
Raw History-Info header value (RFC 7044).
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_raw(&self) -> Option<&str>
fn p_asserted_identity_raw(&self) -> Option<&str>
Raw P-Asserted-Identity header value (RFC 3325).
Sourcefn p_asserted_identity(
&self,
) -> Result<Option<SipHeaderAddr>, ParseSipHeaderAddrError>
fn p_asserted_identity( &self, ) -> Result<Option<SipHeaderAddr>, ParseSipHeaderAddrError>
Parse the P-Asserted-Identity header into a SipHeaderAddr.
Returns Ok(None) if the header is absent, Err if present but unparseable.