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