Skip to main content

freeswitch_types/variables/
mod.rs

1//! Channel variable types: format parsers (`ARRAY::`, SIP multipart) and typed
2//! variable name enums.
3
4mod core;
5mod esl_array;
6mod sip_call_info;
7mod sip_geolocation;
8mod sip_invite;
9mod sip_multipart;
10mod sofia;
11
12pub use self::core::{ChannelVariable, ParseChannelVariableError};
13pub use esl_array::EslArray;
14pub use sip_call_info::{SipCallInfo, SipCallInfoEntry, SipCallInfoError};
15pub use sip_geolocation::{SipGeolocation, SipGeolocationRef};
16pub use sip_invite::{ParseSipInviteHeaderError, SipInviteHeader};
17pub use sip_multipart::{MultipartBody, MultipartItem};
18pub use sofia::{ParseSofiaVariableError, SofiaVariable};
19
20/// Trait for typed channel variable name enums.
21///
22/// Implement this on variable name enums to use them with
23/// [`HeaderLookup::variable()`](crate::HeaderLookup::variable) and
24/// [`variable_str()`](crate::HeaderLookup::variable_str).
25/// For variables not covered by any typed enum, use `variable_str()`.
26pub trait VariableName {
27    /// Wire-format variable name (e.g. `"sip_call_id"`).
28    fn as_str(&self) -> &str;
29}
30
31impl VariableName for ChannelVariable {
32    fn as_str(&self) -> &str {
33        ChannelVariable::as_str(self)
34    }
35}
36
37impl VariableName for SofiaVariable {
38    fn as_str(&self) -> &str {
39        SofiaVariable::as_str(self)
40    }
41}
42
43impl VariableName for SipInviteHeader {
44    fn as_str(&self) -> &str {
45        SipInviteHeader::as_str(self)
46    }
47}