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