Skip to main content

EslEvent

Struct EslEvent 

Source
pub struct EslEvent { /* private fields */ }
Expand description

ESL Event structure containing headers and optional body

Implementations§

Source§

impl EslEvent

Source

pub fn new() -> Self

Create a new empty event

Source

pub fn with_type(event_type: EslEventType) -> Self

Create event with the Event-Name header set to the given type’s wire name. The event type is derived lazily from this header on every event_type() call — there is no separate event_type field.

Source

pub fn event_type(&self) -> Option<EslEventType>

Parsed event type, derived from the Event-Name header.

Returns None if the header is missing or carries a value that is not a recognized EslEventType variant. Single source of truth: the header. Mutating Event-Name via set_header will be reflected on the next call.

Source

pub fn header(&self, name: EventHeader) -> Option<&str>

Look up a header by its EventHeader enum variant.

For headers not covered by EventHeader, use header_str().

Source

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

Look up a header by name, in any casing the switch might have spelled it.

Use header() with an EventHeader variant for known headers. This method is for headers not (yet) covered by the enum, such as custom X- headers or FreeSWITCH headers added after this library was published.

Source

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

Look up a channel variable by its bare name.

Equivalent to variable() but matches the HeaderLookup trait signature.

Source

pub fn headers(&self) -> &IndexMap<String, String>

All headers as a map, keyed canonically.

Source

pub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)

Set or overwrite a header, normalizing the key.

Source

pub fn remove_header(&mut self, name: impl AsRef<str>) -> Option<String>

Remove a header, returning its value if it existed.

Accepts both canonical and original (non-normalized) key names.

Source

pub fn body(&self) -> Option<&str>

Event body (the content after the blank line in plain-text events).

Source

pub fn set_body(&mut self, body: impl Into<String>)

Set the event body.

Source

pub fn raw_body(&self) -> Option<&[u8]>

Exact wire bytes of the event body when it was not valid UTF-8.

Some is the lossy signal: body() then holds the U+FFFD-substituted string and these are the original payload bytes (e.g. a Latin-1 SMS body), so the app can re-decode or audit them. For plain and log events these are the inner body bytes. For JSON/XML events, wire bytes cannot be mapped back to the decoded body, so this carries the whole event envelope body (the serialized JSON/XML document as sent on the wire) — the signal is still observable. None in the normal case.

Source

pub fn lossy_values(&self) -> &LossyValues

Headers whose percent-decoded value contained invalid UTF-8 and was decoded lossily (U+FFFD substituted).

Each entry carries the on-wire raw_value() (the percent-encoded source text) so the app can re-decode it (e.g. as Latin-1) or audit it instead of being stuck with the U+FFFD-substituted string in headers. Empty in the normal case.

Source

pub fn set_priority(&mut self, priority: EslEventPriority)

Sets the priority header carried on the event.

FreeSWITCH stores this as metadata but does not use it for dispatch ordering – all events are delivered FIFO regardless of priority.

Source

pub fn push_header( &mut self, name: &str, value: &str, ) -> Result<(), EslArrayError>

Append a value to a multi-value header (PUSH semantics).

If the header doesn’t exist, sets it as a plain value. If it exists as a plain value, converts to ARRAY::old|:new. If it already has an ARRAY:: prefix, appends the new value.

Returns EslArrayError::TooManyItems if the existing header already contains MAX_ARRAY_ITEMS items.

let mut event = EslEvent::new();
event.push_header("X-Test", "first").unwrap();
event.push_header("X-Test", "second").unwrap();
assert_eq!(event.header_str("X-Test"), Some("ARRAY::first|:second"));
Source

pub fn unshift_header( &mut self, name: &str, value: &str, ) -> Result<(), EslArrayError>

Prepend a value to a multi-value header (UNSHIFT semantics).

Same conversion rules as push_header(), but inserts at the front.

let mut event = EslEvent::new();
event.set_header("X-Test", "ARRAY::b|:c");
event.unshift_header("X-Test", "a").unwrap();
assert_eq!(event.header_str("X-Test"), Some("ARRAY::a|:b|:c"));
Source

pub fn is_event_type(&self, event_type: EslEventType) -> bool

Check whether this event matches the given type.

Source

pub fn to_plain_format(&self) -> String

Serialize to ESL plain text wire format with percent-encoded header values.

This is the inverse of EslParser::parse_plain_event(). The output can be fed back through the parser to reconstruct an equivalent EslEvent (round-trip).

Headers are emitted in insertion order (which matches wire order when the event was parsed from the network). Content-Length from stored headers is skipped and recomputed from the body if present.

Trait Implementations§

Source§

impl Clone for EslEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EslEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EslEvent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for EslEvent

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EslEvent

Source§

impl Hash for EslEvent

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl HeaderLookup for EslEvent

Source§

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

Look up a header by its raw wire name (e.g. "Unique-ID").
Source§

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

Look up a channel variable by its bare name (e.g. "sip_call_id"). Read more
Source§

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

Look up a header by its EventHeader enum variant.
Source§

fn variable(&self, name: impl VariableName) -> Option<&str>

Look up a channel variable by its typed enum variant.
Source§

fn first_header<const N: usize>(&self, names: [EventHeader; N]) -> Option<&str>

First of names the store carries, probed in order. Read more
Source§

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

Unique-ID header, falling back to Caller-Unique-ID.
Source§

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

Job-UUID header from bgapi BACKGROUND_JOB events. Read more
Source§

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

Channel-Name header (e.g. sofia/internal/1000@domain).
Source§

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

Endpoint module the emitting channel belongs to, from its own Channel-Name. Read more
Source§

fn loopback_leg(&self) -> Result<Option<LoopbackLeg>, ParseLoopbackLegError>

loopback_leg variable, for a channel already known to be a loopback. Read more
Source§

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

Caller-Caller-ID-Number header.
Source§

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

Caller-Caller-ID-Name header.
Source§

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

Caller-Destination-Number header.
Source§

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

Caller-Callee-ID-Number header.
Source§

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

Caller-Callee-ID-Name header.
Source§

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>

Presence-Call-Direction header, parsed into a CallDirection.
Source§

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

Event-Date-Timestamp header (microseconds since epoch).
Source§

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

Event-Sequence header (sequential event counter).
Source§

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

DTMF-Duration header (digit duration in milliseconds).
Source§

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

DTMF-Source header (e.g. rtp, inband).
Source§

fn hangup_cause(&self) -> Result<Option<HangupCause>, ParseHangupCauseError>

Parse the Hangup-Cause header into a HangupCause. Read more
Source§

fn loopback_resignation(&self) -> Option<LoopbackResignation<'_>>

Detect a mod_loopback bowout on a CHANNEL_HANGUP_COMPLETE. Read more
Source§

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>

Parse Event-Subclass as a typed SofiaEventSubclass. Read more
Source§

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

Gateway header from sofia::gateway_state / sofia::gateway_add events.
Source§

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

Sofia profile name, from whichever of the two wire spellings the event carries. Read more
Source§

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

module_name header – the literal mod_sofia on the events above.
Source§

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

profile_uri header – bind URL of the profile named by profile_name().
Source§

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

Phrase header (SIP reason phrase) from sofia state events.
Source§

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>

Parse the State header as a GatewayRegState. Read more
Source§

fn gateway_ping_status( &self, ) -> Result<Option<GatewayPingStatus>, ParseGatewayPingStatusError>

Parse Ping-Status as a GatewayPingStatus. Read more
Source§

fn sip_user_ping_status( &self, ) -> Result<Option<SipUserPingStatus>, ParseSipUserPingStatusError>

Parse Ping-Status as a SipUserPingStatus. Read more
Source§

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

pl_data header – SIP NOTIFY body content from NOTIFY_IN events. Read more
Source§

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

event header – SIP event package name from NOTIFY_IN events. Read more
Source§

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

gateway_name header – gateway that received a SIP NOTIFY.
Source§

fn channel_state(&self) -> Result<Option<ChannelState>, ParseChannelStateError>

Parse the Channel-State header into a ChannelState. Read more
Source§

fn channel_state_number( &self, ) -> Result<Option<ChannelState>, ParseChannelStateError>

Parse the Channel-State-Number header into a ChannelState. Read more
Source§

fn is_terminal_channel_state(&self) -> Result<bool, ParseChannelStateError>

Whether this event is the one that ends the channel: a CHANNEL_STATE carrying Channel-State: CS_DESTROY. Read more
Source§

fn call_state(&self) -> Result<Option<CallState>, ParseCallStateError>

Parse the Channel-Call-State header into a CallState. Read more
Source§

fn answer_state(&self) -> Result<Option<AnswerState>, ParseAnswerStateError>

Parse the Answer-State header into an AnswerState. Read more
Source§

fn call_direction( &self, ) -> Result<Option<CallDirection>, ParseCallDirectionError>

Parse the Call-Direction header into a CallDirection. Read more
Source§

fn priority(&self) -> Result<Option<EslEventPriority>, ParsePriorityError>

Parse the priority header value. Read more
Source§

fn timetable( &self, prefix: &str, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>

Extract timetable from timestamp headers with the given prefix. Read more
Source§

fn caller_timetable( &self, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>

Caller-leg channel timetable (Caller-*-Time headers).
Source§

fn other_leg_timetable( &self, ) -> Result<Option<ChannelTimetable>, ParseTimetableError>

Other-leg channel timetable (Other-Leg-*-Time headers).
Source§

impl PartialEq for EslEvent

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for EslEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SipHeaderLookup for EslEvent

Source§

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

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

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

Return all occurrences of a header by canonical name. Read more
Source§

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

Look up a SIP header by its SipHeader enum variant.
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. Read more
Source§

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

Parse the History-Info header into a HistoryInfo. Read more
Source§

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

Parse P-Asserted-Identity into a list of SipHeaderAddr. Read more
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). Read more
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 replaces(&self) -> Result<Option<SipReplaces>, SipReplacesError>

Parse Replaces into a SipReplaces (RFC 3891 §6.1). Read more
Source§

fn join(&self) -> Result<Option<SipReplaces>, SipReplacesError>

Parse Join into a SipReplaces (RFC 3911 §7.1). Read more
Source§

fn target_dialog(&self) -> Result<Option<SipTargetDialog>, SipTargetDialogError>

Parse Target-Dialog into a SipTargetDialog (RFC 4538 §7). Read more
Source§

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

Parse Authorization into a list of SipAuthValue (RFC 3261 §20.7). Read more
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).
Source§

fn geolocation(&self) -> Option<SipGeolocation>

Parse every Geolocation row into a SipGeolocation (RFC 6442). Read more
Source§

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

Parse Diversion into a list of SipHeaderAddr (draft-levy-sip-diversion-08).
Source§

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

Parse Remote-Party-ID into a list of SipHeaderAddr (draft-ietf-sip-privacy-01).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.