pub struct EslHeaders { /* private fields */ }Expand description
A flat header store that decodes FreeSWITCH ARRAY and bracket encoding when answering typed SIP header queries.
Construct with EslHeaders::new or EslHeaders::from_map. Use it
anywhere a HeaderLookup or SipHeaderLookup implementor is
expected:
use freeswitch_types::{EslHeaders, HeaderLookup};
use freeswitch_types::sip_header::SipHeaderLookup;
let mut h = EslHeaders::new();
h.insert("Unique-ID", "abc-123");
h.insert("Call-Info", "ARRAY::<sip:a@example.com>;purpose=icon|:<sip:b@example.com>");
assert_eq!(h.header_str("Unique-ID"), Some("abc-123"));
let ci = h.call_info().unwrap().unwrap();
assert_eq!(ci.entries().len(), 2);HeaderLookup delegates straight to the map; SipHeaderLookup methods
that parse RFC-structured values (call_info, history_info, and any
future multi-value parsers) first peel the FreeSWITCH encoding and then
hand pre-split entries to sip-header. Non-parsing lookups
(sip_header_str, sip_header) return the raw stored value untouched —
the caller sees exactly what FreeSWITCH put on the wire.
Every write normalizes its key with
normalize_header_key, so a payload
spelling one header two ways collapses to one entry, and every read falls
back to a lowercase alias, so a query in any casing resolves. Keys
containing _ are exempt from both: their suffix carries SIP wire casing.
Implementations§
Source§impl EslHeaders
impl EslHeaders
Sourcepub fn from_map(map: IndexMap<String, String>) -> Self
pub fn from_map(map: IndexMap<String, String>) -> Self
Wrap an existing map, normalizing every key.
Sourcepub fn as_map(&self) -> &IndexMap<String, String>
pub fn as_map(&self) -> &IndexMap<String, String>
Access the underlying map, keyed canonically.
Sourcepub fn into_map(self) -> IndexMap<String, String>
pub fn into_map(self) -> IndexMap<String, String>
Consume and return the underlying map, keyed canonically.
Sourcepub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn insert(&mut self, key: impl Into<String>, value: impl Into<String>)
Insert a header under its canonical key, replacing any entry there.
Source§impl EslHeaders
impl EslHeaders
Sourcepub fn parse_uri_info(value: &str) -> Result<UriInfo, UriInfoError>
pub fn parse_uri_info(value: &str) -> Result<UriInfo, UriInfoError>
Parse a FreeSWITCH-transported SIP URI-list value into typed UriInfo
entries, handling both ARRAY:: encoding and bracket wrapping.
Use this when you hold a raw value — e.g. the sip_call_info /
sip_alert_info channel variable fetched over ESL — rather than a
populated EslHeaders. It accepts any of the forms FreeSWITCH emits:
- Single RFC entry:
<sip:a@example.test>;purpose=emergency-CallId - ARRAY encoding:
ARRAY::<sip:a@example.test>;purpose=icon|:<sip:b@example.test> - Bracket-wrapped:
[<sip:a@example.test>;purpose=icon]
This is the same decoding the call_info
and alert_info methods apply; iterate
the result via .entries().
§Errors
Returns UriInfoError if the value is malformed or if the ARRAY::
structure is invalid. Structural EslArrayError cases (e.g.
TooManyItems) are surfaced as UriInfoError::Malformed carrying
the cause.
§Example
use freeswitch_types::EslHeaders;
let value = "ARRAY::<urn:emergency:uid:callid:bcf.test>;purpose=emergency-CallId\
|:<urn:emergency:uid:incidentid:bcf.test>;purpose=emergency-IncidentId";
let info = EslHeaders::parse_uri_info(value).unwrap();
assert_eq!(info.entries().len(), 2);Sourcepub fn split_entries(value: &str) -> Result<Vec<String>, EslArrayError>
pub fn split_entries(value: &str) -> Result<Vec<String>, EslArrayError>
Split one comma-list SIP header value held as an ESL variable into its
entries, applying the same decoding as parse_uri_info
and parse_history_info: bracket unwrapping,
ARRAY:: splitting, then the RFC comma split of each item.
Only for headers that are lists (Call-Info, Alert-Info,
History-Info, Diversion, …). A header whose value legitimately
contains commas without being a list — Date, Subject, User-Agent —
must not go through it.
§Errors
A missing ARRAY:: prefix is the RFC form, not an error. Every other
EslArrayError is a structural fault in the ESL encoding and is
returned as-is. An empty or whitespace-only value yields no entries,
which the typed parsers turn into their own Empty error.
use freeswitch_types::EslHeaders;
let entries =
EslHeaders::split_entries("ARRAY::<sip:a@example.test>|:<sip:b@example.test>").unwrap();
assert_eq!(entries, ["<sip:a@example.test>", "<sip:b@example.test>"]);Sourcepub fn parse_history_info(value: &str) -> Result<HistoryInfo, HistoryInfoError>
pub fn parse_history_info(value: &str) -> Result<HistoryInfo, HistoryInfoError>
Parse a FreeSWITCH-transported History-Info value into a typed
HistoryInfo, handling both ARRAY:: encoding and bracket wrapping.
The raw-value counterpart to history_info.
§Errors
Structural EslArrayError cases (e.g. TooManyItems) are surfaced as
HistoryInfoError::Malformed carrying the cause.
Trait Implementations§
Source§impl Clone for EslHeaders
impl Clone for EslHeaders
Source§impl Debug for EslHeaders
impl Debug for EslHeaders
Source§impl Default for EslHeaders
impl Default for EslHeaders
Source§impl<'de> Deserialize<'de> for EslHeaders
Available on crate feature serde only.
impl<'de> Deserialize<'de> for EslHeaders
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for EslHeaders
Source§impl<K: Into<String>, V: Into<String>> Extend<(K, V)> for EslHeaders
impl<K: Into<String>, V: Into<String>> Extend<(K, V)> for EslHeaders
Source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<K: Into<String>, V: Into<String>> FromIterator<(K, V)> for EslHeaders
impl<K: Into<String>, V: Into<String>> FromIterator<(K, V)> for EslHeaders
Source§impl HeaderLookup for EslHeaders
impl HeaderLookup for EslHeaders
Source§fn header_str(&self, name: &str) -> Option<&str>
fn header_str(&self, name: &str) -> Option<&str>
"Unique-ID").Source§fn variable_str(&self, name: &str) -> Option<&str>
fn variable_str(&self, name: &str) -> Option<&str>
"sip_call_id"). Read moreSource§fn header(&self, name: EventHeader) -> Option<&str>
fn header(&self, name: EventHeader) -> Option<&str>
EventHeader enum variant.Source§fn variable(&self, name: impl VariableName) -> Option<&str>
fn variable(&self, name: impl VariableName) -> Option<&str>
Source§fn first_header<const N: usize>(&self, names: [EventHeader; N]) -> Option<&str>
fn first_header<const N: usize>(&self, names: [EventHeader; N]) -> Option<&str>
names the store carries, probed in order. Read moreSource§fn channel_name(&self) -> Option<&str>
fn channel_name(&self) -> Option<&str>
Channel-Name header (e.g. sofia/internal/1000@domain).Source§fn channel_driver(&self) -> Option<&str>
fn channel_driver(&self) -> Option<&str>
Channel-Name. Read moreSource§fn loopback_leg(&self) -> Result<Option<LoopbackLeg>, ParseLoopbackLegError>
fn loopback_leg(&self) -> Result<Option<LoopbackLeg>, ParseLoopbackLegError>
loopback_leg variable, for a channel already known to be a loopback. Read moreSource§fn caller_id_number(&self) -> Option<&str>
fn caller_id_number(&self) -> Option<&str>
Caller-Caller-ID-Number header.Source§fn caller_id_name(&self) -> Option<&str>
fn caller_id_name(&self) -> Option<&str>
Caller-Caller-ID-Name header.Source§fn destination_number(&self) -> Option<&str>
fn destination_number(&self) -> Option<&str>
Caller-Destination-Number header.Source§fn callee_id_number(&self) -> Option<&str>
fn callee_id_number(&self) -> Option<&str>
Caller-Callee-ID-Number header.Source§fn callee_id_name(&self) -> Option<&str>
fn callee_id_name(&self) -> Option<&str>
Caller-Callee-ID-Name header.Source§fn channel_presence_id(&self) -> Option<&str>
fn channel_presence_id(&self) -> Option<&str>
Channel-Presence-ID header (e.g. 1000@example.com).Source§fn presence_call_direction(
&self,
) -> Result<Option<CallDirection>, ParseCallDirectionError>
fn presence_call_direction( &self, ) -> Result<Option<CallDirection>, ParseCallDirectionError>
Presence-Call-Direction header, parsed into a CallDirection.Source§fn event_date_timestamp(&self) -> Option<&str>
fn event_date_timestamp(&self) -> Option<&str>
Event-Date-Timestamp header (microseconds since epoch).Source§fn event_sequence(&self) -> Option<&str>
fn event_sequence(&self) -> Option<&str>
Event-Sequence header (sequential event counter).Source§fn dtmf_duration(&self) -> Option<&str>
fn dtmf_duration(&self) -> Option<&str>
DTMF-Duration header (digit duration in milliseconds).Source§fn dtmf_source(&self) -> Option<&str>
fn dtmf_source(&self) -> Option<&str>
DTMF-Source header (e.g. rtp, inband).Source§fn hangup_cause(&self) -> Result<Option<HangupCause>, ParseHangupCauseError>
fn hangup_cause(&self) -> Result<Option<HangupCause>, ParseHangupCauseError>
Source§fn loopback_resignation(&self) -> Option<LoopbackResignation<'_>>
fn loopback_resignation(&self) -> Option<LoopbackResignation<'_>>
CHANNEL_HANGUP_COMPLETE. Read moreSource§fn event_subclass(&self) -> Option<&str>
fn event_subclass(&self) -> Option<&str>
Event-Subclass header for CUSTOM events (e.g. sofia::register).Source§fn sofia_event_subclass(
&self,
) -> Result<Option<SofiaEventSubclass>, ParseSofiaEventSubclassError>
fn sofia_event_subclass( &self, ) -> Result<Option<SofiaEventSubclass>, ParseSofiaEventSubclassError>
Source§fn gateway(&self) -> Option<&str>
fn gateway(&self) -> Option<&str>
Gateway header from sofia::gateway_state / sofia::gateway_add events.Source§fn profile_name(&self) -> Option<&str>
fn profile_name(&self) -> Option<&str>
Source§fn module_name(&self) -> Option<&str>
fn module_name(&self) -> Option<&str>
module_name header – the literal mod_sofia on the events above.Source§fn profile_uri(&self) -> Option<&str>
fn profile_uri(&self) -> Option<&str>
profile_uri header – bind URL of the profile named by
profile_name().Source§fn sip_status_code(&self) -> Result<Option<u16>, ParseIntError>
fn sip_status_code(&self) -> Result<Option<u16>, ParseIntError>
Status header (SIP response code) from sofia::gateway_state and
sofia::sip_user_state events.Source§fn gateway_reg_state(
&self,
) -> Result<Option<GatewayRegState>, ParseGatewayRegStateError>
fn gateway_reg_state( &self, ) -> Result<Option<GatewayRegState>, ParseGatewayRegStateError>
Source§fn gateway_ping_status(
&self,
) -> Result<Option<GatewayPingStatus>, ParseGatewayPingStatusError>
fn gateway_ping_status( &self, ) -> Result<Option<GatewayPingStatus>, ParseGatewayPingStatusError>
Source§fn sip_user_ping_status(
&self,
) -> Result<Option<SipUserPingStatus>, ParseSipUserPingStatusError>
fn sip_user_ping_status( &self, ) -> Result<Option<SipUserPingStatus>, ParseSipUserPingStatusError>
Source§fn gateway_name(&self) -> Option<&str>
fn gateway_name(&self) -> Option<&str>
gateway_name header – gateway that received a SIP NOTIFY.Source§fn channel_state(&self) -> Result<Option<ChannelState>, ParseChannelStateError>
fn channel_state(&self) -> Result<Option<ChannelState>, ParseChannelStateError>
Source§fn channel_state_number(
&self,
) -> Result<Option<ChannelState>, ParseChannelStateError>
fn channel_state_number( &self, ) -> Result<Option<ChannelState>, ParseChannelStateError>
Source§fn is_terminal_channel_state(&self) -> Result<bool, ParseChannelStateError>
fn is_terminal_channel_state(&self) -> Result<bool, ParseChannelStateError>
CHANNEL_STATE
carrying Channel-State: CS_DESTROY. Read moreSource§fn call_state(&self) -> Result<Option<CallState>, ParseCallStateError>
fn call_state(&self) -> Result<Option<CallState>, ParseCallStateError>
Source§fn answer_state(&self) -> Result<Option<AnswerState>, ParseAnswerStateError>
fn answer_state(&self) -> Result<Option<AnswerState>, ParseAnswerStateError>
Source§fn call_direction(
&self,
) -> Result<Option<CallDirection>, ParseCallDirectionError>
fn call_direction( &self, ) -> Result<Option<CallDirection>, ParseCallDirectionError>
Source§fn priority(&self) -> Result<Option<EslEventPriority>, ParsePriorityError>
fn priority(&self) -> Result<Option<EslEventPriority>, ParsePriorityError>
priority header value. Read moreSource§fn timetable(
&self,
prefix: &str,
) -> Result<Option<ChannelTimetable>, ParseTimetableError>
fn timetable( &self, prefix: &str, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>
Source§fn caller_timetable(
&self,
) -> Result<Option<ChannelTimetable>, ParseTimetableError>
fn caller_timetable( &self, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>
Caller-*-Time headers).Source§fn other_leg_timetable(
&self,
) -> Result<Option<ChannelTimetable>, ParseTimetableError>
fn other_leg_timetable( &self, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>
Other-Leg-*-Time headers).Source§impl PartialEq for EslHeaders
impl PartialEq for EslHeaders
Source§impl Serialize for EslHeaders
impl Serialize for EslHeaders
Source§impl SipHeaderLookup for EslHeaders
impl SipHeaderLookup for EslHeaders
Source§fn sip_header_str(&self, name: &str) -> Option<&str>
fn sip_header_str(&self, name: &str) -> Option<&str>
"Call-Info").Source§fn 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>
Source§fn sip_header(&self, name: SipHeader) -> Option<&str>
fn sip_header(&self, name: SipHeader) -> Option<&str>
SipHeader enum variant.Source§fn sip_header_all(&self, name: SipHeader) -> Vec<&str>
fn sip_header_all(&self, name: SipHeader) -> Vec<&str>
SipHeader variant.Source§fn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError>
fn history_info(&self) -> Result<Option<HistoryInfo>, HistoryInfoError>
Source§fn p_asserted_identity(
&self,
) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn p_asserted_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Source§fn p_preferred_identity(
&self,
) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn p_preferred_identity( &self, ) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
P-Preferred-Identity into a list of SipHeaderAddr (RFC 3325).Source§fn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Route into a list of SipHeaderAddr (RFC 3261 §20.34).Source§fn record_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn record_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Record-Route into a list of SipHeaderAddr (RFC 3261 §20.30).Source§fn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn path(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Path into a list of SipHeaderAddr (RFC 3327).Source§fn service_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn service_route(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Service-Route into a list of SipHeaderAddr (RFC 3608).Source§fn contact(&self) -> Result<Vec<ContactValue>, ParseSipHeaderAddrError>
fn contact(&self) -> Result<Vec<ContactValue>, ParseSipHeaderAddrError>
Source§fn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError>
fn alert_info(&self) -> Result<Option<UriInfo>, UriInfoError>
Alert-Info into a UriInfo (RFC 3261 §20.4).Source§fn error_info(&self) -> Result<Option<UriInfo>, UriInfoError>
fn error_info(&self) -> Result<Option<UriInfo>, UriInfoError>
Error-Info into a UriInfo (RFC 3261 §20.18).Source§fn allow(&self) -> Vec<&str>
fn allow(&self) -> Vec<&str>
Allow header values as individual method tokens (RFC 3261 §20.5).Source§fn supported(&self) -> Vec<&str>
fn supported(&self) -> Vec<&str>
Supported header values as individual option-tag tokens (RFC 3261 §20.37).Source§fn require_header(&self) -> Vec<&str>
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>
fn proxy_require(&self) -> Vec<&str>
Proxy-Require values as individual option-tag tokens (RFC 3261 §20.29).Source§fn unsupported(&self) -> Vec<&str>
fn unsupported(&self) -> Vec<&str>
Unsupported values as individual option-tag tokens (RFC 3261 §20.40).Source§fn allow_events(&self) -> Vec<&str>
fn allow_events(&self) -> Vec<&str>
Allow-Events values as individual event-type tokens (RFC 6665).Source§fn content_encoding(&self) -> Vec<&str>
fn content_encoding(&self) -> Vec<&str>
Content-Encoding values as individual tokens (RFC 3261 §20.12).Source§fn content_language(&self) -> Vec<&str>
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>
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>
fn via(&self) -> Result<Option<SipVia>, SipViaError>
Via into a SipVia (RFC 3261 §20.42).Source§fn replaces(&self) -> Result<Option<SipReplaces>, SipReplacesError>
fn replaces(&self) -> Result<Option<SipReplaces>, SipReplacesError>
Source§fn join(&self) -> Result<Option<SipReplaces>, SipReplacesError>
fn join(&self) -> Result<Option<SipReplaces>, SipReplacesError>
Source§fn target_dialog(&self) -> Result<Option<SipTargetDialog>, SipTargetDialogError>
fn target_dialog(&self) -> Result<Option<SipTargetDialog>, SipTargetDialogError>
Proxy-Authorization into a list of SipAuthValue (RFC 3261 §20.28).Source§fn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
fn www_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
WWW-Authenticate into a list of SipAuthValue (RFC 3261 §20.44).Source§fn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
fn proxy_authenticate(&self) -> Result<Vec<SipAuthValue>, SipAuthError>
Proxy-Authenticate into a list of SipAuthValue (RFC 3261 §20.27).Source§fn warning(&self) -> Result<Option<SipWarning>, SipWarningError>
fn warning(&self) -> Result<Option<SipWarning>, SipWarningError>
Warning into a SipWarning (RFC 3261 §20.43).Source§fn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_client(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Security-Client into a SipSecurity (RFC 3329).Source§fn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_server(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Security-Server into a SipSecurity (RFC 3329).Source§fn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError>
fn security_verify(&self) -> Result<Option<SipSecurity>, SipSecurityError>
Security-Verify into a SipSecurity (RFC 3329).Source§fn accept(&self) -> Result<Option<SipAccept>, SipAcceptError>
fn accept(&self) -> Result<Option<SipAccept>, SipAcceptError>
Accept into a SipAccept (RFC 3261 §20.1).Source§fn accept_encoding(
&self,
) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError>
fn accept_encoding( &self, ) -> Result<Option<SipAcceptEncoding>, SipAcceptEncodingError>
Accept-Encoding into a SipAcceptEncoding (RFC 3261 §20.2).Source§fn accept_language(
&self,
) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError>
fn accept_language( &self, ) -> Result<Option<SipAcceptLanguage>, SipAcceptLanguageError>
Accept-Language into a SipAcceptLanguage (RFC 3261 §20.3).Source§fn geolocation(&self) -> Option<SipGeolocation>
fn geolocation(&self) -> Option<SipGeolocation>
Source§fn diversion(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn diversion(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Diversion into a list of SipHeaderAddr (draft-levy-sip-diversion-08).Source§fn remote_party_id(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
fn remote_party_id(&self) -> Result<Vec<SipHeaderAddr>, ParseSipHeaderAddrError>
Remote-Party-ID into a list of SipHeaderAddr (draft-ietf-sip-privacy-01).impl StructuralPartialEq for EslHeaders
Auto Trait Implementations§
impl Freeze for EslHeaders
impl RefUnwindSafe for EslHeaders
impl Send for EslHeaders
impl Sync for EslHeaders
impl Unpin for EslHeaders
impl UnsafeUnpin for EslHeaders
impl UnwindSafe for EslHeaders
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.