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 core_media;
6mod esl_array;
7#[cfg(feature = "esl")]
8mod esl_headers;
9mod sip_multipart;
10mod sip_passthrough;
11mod sofia;
12
13pub use self::core::{ChannelVariable, ParseChannelVariableError};
14pub use core_media::{CoreMediaVariable, ParseCoreMediaVariableError, RtpStatUnit};
15pub use esl_array::{EslArray, EslArrayError, MAX_ARRAY_ITEMS};
16#[cfg(feature = "esl")]
17pub use esl_headers::EslHeaders;
18pub use sip_multipart::{MultipartBody, MultipartItem};
19pub use sip_passthrough::{
20    InvalidHeaderName, ParseSipPassthroughError, SipHeaderPrefix, SipPassthroughHeader,
21};
22pub use sofia::{ParseSofiaVariableError, SofiaVariable};
23
24/// Trait for typed channel variable name enums.
25///
26/// Implement this on variable name enums to use them with
27/// [`HeaderLookup::variable()`](crate::HeaderLookup::variable) and
28/// [`variable_str()`](crate::HeaderLookup::variable_str).
29/// For variables not covered by any typed enum, use `variable_str()`.
30pub trait VariableName {
31    /// Wire-format variable name (e.g. `"sip_call_id"`).
32    fn as_str(&self) -> &str;
33}
34
35impl VariableName for ChannelVariable {
36    fn as_str(&self) -> &str {
37        ChannelVariable::as_str(self)
38    }
39}
40
41impl VariableName for SofiaVariable {
42    fn as_str(&self) -> &str {
43        SofiaVariable::as_str(self)
44    }
45}
46
47impl VariableName for CoreMediaVariable {
48    fn as_str(&self) -> &str {
49        CoreMediaVariable::as_str(self)
50    }
51}