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;
7mod sip_multipart;
8mod sip_passthrough;
9mod sofia;
10
11pub use self::core::{ChannelVariable, ParseChannelVariableError};
12pub use core_media::{CoreMediaVariable, ParseCoreMediaVariableError, RtpStatUnit};
13pub use esl_array::EslArray;
14pub use sip_multipart::{MultipartBody, MultipartItem};
15pub use sip_passthrough::{
16    InvalidHeaderName, ParseSipPassthroughError, SipHeaderPrefix, SipPassthroughHeader,
17};
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 CoreMediaVariable {
44    fn as_str(&self) -> &str {
45        CoreMediaVariable::as_str(self)
46    }
47}