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_multipart;
7mod sofia;
8
9pub use self::core::{ChannelVariable, ParseChannelVariableError};
10pub use esl_array::EslArray;
11pub use sip_multipart::{MultipartBody, MultipartItem};
12pub use sofia::{ParseSofiaVariableError, SofiaVariable};
13
14/// Trait for typed channel variable name enums.
15///
16/// Implement this on variable name enums to use them with
17/// [`HeaderLookup::variable()`](crate::HeaderLookup::variable) and
18/// [`variable_str()`](crate::HeaderLookup::variable_str).
19/// For variables not covered by any typed enum, use `variable_str()`.
20pub trait VariableName {
21    /// Wire-format variable name (e.g. `"sip_call_id"`).
22    fn as_str(&self) -> &str;
23}
24
25impl VariableName for ChannelVariable {
26    fn as_str(&self) -> &str {
27        ChannelVariable::as_str(self)
28    }
29}
30
31impl VariableName for SofiaVariable {
32    fn as_str(&self) -> &str {
33        SofiaVariable::as_str(self)
34    }
35}