Skip to main content

SipHeaderLookup

Trait SipHeaderLookup 

Source
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§

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 call_info_raw(&self) -> Option<&str>

Raw Call-Info header value (RFC 3261 section 20.9).

Source

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.

Source

fn history_info_raw(&self) -> Option<&str>

Raw History-Info header value (RFC 7044).

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_raw(&self) -> Option<&str>

Raw P-Asserted-Identity header value (RFC 3325).

Source

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.

Implementations on Foreign Types§

Source§

impl SipHeaderLookup for HashMap<String, String>

Source§

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

Implementors§