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