Skip to main content

freeswitch_types/
lib.rs

1// The esl_event_types! macro uses TT-munching filter arms over ~90 variants,
2// requiring a higher recursion limit than the default 128.
3#![recursion_limit = "512"]
4
5//! FreeSWITCH protocol types: channel state, events, headers, commands, and variables.
6//!
7//! This crate provides the domain types for FreeSWITCH's Event Socket Library (ESL)
8//! protocol without any async runtime dependency. Use it standalone for CDR parsing,
9//! config generation, command building, or channel variable validation.
10//!
11//! For async ESL transport (connecting to FreeSWITCH, sending commands, receiving events),
12//! see the [`freeswitch-esl-tokio`](https://docs.rs/freeswitch-esl-tokio) crate which
13//! re-exports everything from this crate.
14//!
15//! # SIP header types
16//!
17//! General-purpose SIP header parsing is provided by the
18//! [`sip-header`](https://docs.rs/sip-header) crate, re-exported here for convenience.
19//! Types like [`SipHeaderAddr`], [`UriInfo`], [`HistoryInfo`], and [`SipGeolocation`]
20//! are available from the crate root.
21
22pub use sip_header;
23pub use sip_header::define_header_enum;
24pub use sip_header::sip_uri;
25
26#[macro_use]
27mod macros;
28
29pub mod channel;
30#[cfg(feature = "esl")]
31pub mod commands;
32#[cfg(feature = "esl")]
33pub mod event;
34pub mod headers;
35pub mod log_level;
36pub mod lookup;
37#[cfg(feature = "esl")]
38pub mod lossy_values;
39pub mod prelude;
40#[cfg(feature = "sdp")]
41pub mod sdp;
42pub mod sofia;
43#[cfg(any(feature = "esl", feature = "sdp"))]
44pub(crate) mod switch_passes;
45#[cfg(all(test, feature = "esl"))]
46mod test_text;
47pub mod variables;
48pub mod version;
49#[doc(hidden)]
50pub mod wire_safety;
51
52/// Default FreeSWITCH ESL port for inbound connections.
53pub const DEFAULT_ESL_PORT: u16 = 8021;
54
55/// Default FreeSWITCH ESL password (`ClueCon`).
56pub const DEFAULT_ESL_PASSWORD: &str = "ClueCon";
57
58/// Header-name prefix a channel variable carries in an event.
59///
60/// Compose with [`VariableName::header_name()`](crate::VariableName::header_name)
61/// rather than by hand.
62pub const VARIABLE_PREFIX: &str = "variable_";
63
64pub use channel::{
65    channel_driver, AnswerState, CallDirection, CallState, ChannelState, ChannelTimetable,
66    HangupCause, ParseAnswerStateError, ParseCallDirectionError, ParseCallStateError,
67    ParseChannelStateError, ParseHangupCauseError, ParseTimetableError, TimetableField,
68    TimetablePrefix,
69};
70#[cfg(feature = "esl")]
71pub use commands::{
72    Application, BlockParse, BridgeDialString, BridgeDialStringDisplay, DialString,
73    DialStringCarrier, DialStringTarget, DialplanType, Endpoint, EndpointDisplay,
74    EndpointFieldFault, ExecuteOn, ExecuteOnFault, GroupCallOrder, InvalidArgvSeparator, Originate,
75    OriginateDisplay, OriginateError, OriginateTarget, ParseBlockParseError,
76    ParseDialplanTypeError, ParseGroupCallOrderError, ParseHoldActionError, ParseMuteActionError,
77    UnvouchedVersion, UuidAnswer, UuidBridge, UuidDeflect, UuidGetVar, UuidHold, UuidKill,
78    UuidSendDtmf, UuidSetVar, UuidTransfer, Variables, VariablesDisplay, VariablesType,
79};
80#[cfg(feature = "esl")]
81pub use event::{
82    EslEvent, EslEventPriority, EslEventType, EventFormat, EventSubscription,
83    EventSubscriptionError, ParseEventFormatError, ParseEventTypeError, ParsePriorityError,
84};
85pub use headers::{case_alias_key, normalize_header_key, EventHeader, ParseEventHeaderError};
86pub use log_level::{LogLevel, ParseLogLevelError};
87pub use lookup::{variable_key, HeaderLookup, ParseHeaderError};
88#[cfg(feature = "esl")]
89pub use lossy_values::{LossyValue, LossyValues};
90pub use sip_header::{
91    extract_header, HistoryInfo, HistoryInfoEntry, HistoryInfoError, HistoryInfoReason,
92    ParseSipHeaderAddrError, ParseSipHeaderError, SipGeolocation, SipGeolocationRef, SipHeader,
93    SipHeaderAddr, SipHeaderLookup, UriInfo, UriInfoEntry, UriInfoError,
94};
95pub use sofia::{
96    GatewayPingStatus, GatewayRegState, ParseGatewayPingStatusError, ParseGatewayRegStateError,
97    ParseSipUserPingStatusError, ParseSofiaEventSubclassError, SipUserPingStatus, SofiaChannelName,
98    SofiaEventSubclass,
99};
100#[cfg(feature = "esl")]
101pub use variables::EslHeaders;
102pub use variables::{
103    CarriedHeader, ChannelVariable, CoreMediaVariable, EslArray, EslArrayError, InvalidHeaderName,
104    MultipartBody, MultipartBodyError, MultipartItem, ParseChannelVariableError,
105    ParseCoreMediaVariableError, ParseSipPassthroughError, RtpStatUnit, SipHeaderPrefix,
106    SipPassthroughHeader, VariableName, MAX_ARRAY_ITEMS,
107};
108pub use version::{FreeswitchVersion, ParseFreeswitchVersionError};
109
110#[cfg(all(doctest, feature = "esl"))]
111mod readme {
112    #![doc = include_str!("../README.md")]
113}