pub struct EslEvent { /* private fields */ }Expand description
ESL Event structure containing headers and optional body
Implementations§
Source§impl EslEvent
impl EslEvent
Sourcepub fn with_type(event_type: EslEventType) -> Self
pub fn with_type(event_type: EslEventType) -> Self
Create event with specified type
Sourcepub fn event_type(&self) -> Option<EslEventType>
pub fn event_type(&self) -> Option<EslEventType>
Parsed event type, if recognized.
Sourcepub fn set_event_type(&mut self, event_type: Option<EslEventType>)
pub fn set_event_type(&mut self, event_type: Option<EslEventType>)
Override the event type.
Sourcepub fn header(&self, name: EventHeader) -> Option<&str>
pub fn header(&self, name: EventHeader) -> Option<&str>
Look up a header by its EventHeader enum variant (case-sensitive).
For headers not covered by EventHeader, use header_str().
Sourcepub fn header_str(&self, name: &str) -> Option<&str>
pub fn header_str(&self, name: &str) -> Option<&str>
Look up a header by name, trying the canonical key first then falling back through the alias map for non-canonical lookups.
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.
Sourcepub fn variable_str(&self, name: &str) -> Option<&str>
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.
Sourcepub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn set_header(&mut self, name: impl Into<String>, value: impl Into<String>)
Set or overwrite a header, normalizing the key.
Sourcepub fn remove_header(&mut self, name: impl AsRef<str>) -> Option<String>
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.
Sourcepub fn body(&self) -> Option<&str>
pub fn body(&self) -> Option<&str>
Event body (the content after the blank line in plain-text events).
Sourcepub fn set_priority(&mut self, priority: EslEventPriority)
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.
Sourcepub fn push_header(&mut self, name: &str, value: &str)
pub fn push_header(&mut self, name: &str, value: &str)
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.
let mut event = EslEvent::new();
event.push_header("X-Test", "first");
event.push_header("X-Test", "second");
assert_eq!(event.header_str("X-Test"), Some("ARRAY::first|:second"));Sourcepub fn unshift_header(&mut self, name: &str, value: &str)
pub fn unshift_header(&mut self, name: &str, value: &str)
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");
assert_eq!(event.header_str("X-Test"), Some("ARRAY::a|:b|:c"));Sourcepub fn is_event_type(&self, event_type: EslEventType) -> bool
pub fn is_event_type(&self, event_type: EslEventType) -> bool
Check whether this event matches the given type.
Sourcepub fn to_plain_format(&self) -> String
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).
Event-Name is emitted first, remaining headers are sorted alphabetically
for deterministic output. Content-Length from stored headers is skipped
and recomputed from the body if present.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EslEvent
Available on crate feature serde only.
impl<'de> Deserialize<'de> for EslEvent
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>,
Source§impl HeaderLookup for EslEvent
impl HeaderLookup for EslEvent
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 channel_name(&self) -> Option<&str>
fn channel_name(&self) -> Option<&str>
Channel-Name header (e.g. sofia/internal/1000@domain).Source§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 hangup_cause(&self) -> Result<Option<HangupCause>, ParseHangupCauseError>
fn hangup_cause(&self) -> Result<Option<HangupCause>, ParseHangupCauseError>
Source§fn event_subclass(&self) -> Option<&str>
fn event_subclass(&self) -> Option<&str>
Event-Subclass header for CUSTOM events (e.g. sofia::register).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 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).impl Eq for EslEvent
Auto Trait Implementations§
impl Freeze for EslEvent
impl RefUnwindSafe for EslEvent
impl Send for EslEvent
impl Sync for EslEvent
impl Unpin for EslEvent
impl UnsafeUnpin for EslEvent
impl UnwindSafe for EslEvent
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,
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.