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