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