Skip to main content

ChannelTimetable

Struct ChannelTimetable 

Source
#[non_exhaustive]
pub struct ChannelTimetable { pub profile_created: Option<i64>, pub created: Option<i64>, pub answered: Option<i64>, pub progress: Option<i64>, pub progress_media: Option<i64>, pub hungup: Option<i64>, pub transferred: Option<i64>, pub resurrected: Option<i64>, pub bridged: Option<i64>, pub last_hold: Option<i64>, pub hold_accum: Option<i64>, }
Expand description

Channel timing data from FreeSWITCH’s switch_channel_timetable_t.

Timestamps are epoch microseconds (i64). A value of 0 means the corresponding event never occurred (e.g., hungup == Some(0) means the channel has not hung up yet). None means the header was absent or unparseable.

Extracted from ESL event headers using a prefix (typically "Caller" or "Other-Leg"). The wire header format is {prefix}-{suffix}, e.g. Caller-Channel-Created-Time.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§profile_created: Option<i64>

When the caller profile was created.

§created: Option<i64>

When the channel was created.

§answered: Option<i64>

When the channel was answered.

§progress: Option<i64>

When early media (183) was received.

§progress_media: Option<i64>

When media-bearing early media arrived.

§hungup: Option<i64>

When the channel hung up.

§transferred: Option<i64>

When the channel was transferred.

§resurrected: Option<i64>

When the channel was resurrected.

§bridged: Option<i64>

When the channel was bridged.

§last_hold: Option<i64>

Timestamp of the last hold event.

§hold_accum: Option<i64>

Accumulated hold time in microseconds.

Implementations§

Source§

impl ChannelTimetable

Source

pub fn from_lookup<'a>( prefix: impl AsRef<str>, lookup: impl Fn(&str) -> Option<&'a str>, ) -> Result<Option<Self>, ParseTimetableError>

Extract a timetable by looking up prefixed header names via a closure.

The closure receives full header names (e.g. "Caller-Channel-Created-Time") and should return the raw value if present. Works with any key-value store: HashMap<String, String>, EslEvent, BTreeMap, etc.

Returns Ok(None) if no timestamp headers with this prefix are present. Returns Err if a header is present but contains an invalid (non-i64) value.

use std::collections::HashMap;
use freeswitch_types::{ChannelTimetable, TimetablePrefix};

let mut headers: HashMap<String, String> = HashMap::new();
headers.insert("Caller-Channel-Created-Time".into(), "1700000001000000".into());

// With enum:
let tt = ChannelTimetable::from_lookup(TimetablePrefix::Caller, |k| headers.get(k).map(|v: &String| v.as_str()));
assert!(tt.unwrap().unwrap().created.is_some());

// With raw string (e.g. for dynamic "Call-1" prefix):
let tt = ChannelTimetable::from_lookup("Caller", |k| headers.get(k).map(|v: &String| v.as_str()));
assert!(tt.unwrap().unwrap().created.is_some());

Trait Implementations§

Source§

impl Clone for ChannelTimetable

Source§

fn clone(&self) -> ChannelTimetable

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ChannelTimetable

Source§

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

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

impl Default for ChannelTimetable

Source§

fn default() -> ChannelTimetable

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

impl<'de> Deserialize<'de> for ChannelTimetable

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 PartialEq for ChannelTimetable

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ChannelTimetable

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 Copy for ChannelTimetable

Source§

impl Eq for ChannelTimetable

Source§

impl StructuralPartialEq for ChannelTimetable

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<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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