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 tokenizer;
45pub mod variables;
46pub mod version;
47#[doc(hidden)]
48pub mod wire_safety;
49
50/// Default FreeSWITCH ESL port for inbound connections.
51pub const DEFAULT_ESL_PORT: u16 = 8021;
52
53/// Default FreeSWITCH ESL password (`ClueCon`).
54pub const DEFAULT_ESL_PASSWORD: &str = "ClueCon";
55
56/// Header-name prefix a channel variable carries in an event.
57///
58/// Compose with [`VariableName::header_name()`](crate::VariableName::header_name)
59/// rather than by hand.
60pub const VARIABLE_PREFIX: &str = "variable_";
61
62pub use channel::{
63    channel_driver, AnswerState, CallDirection, CallState, ChannelState, ChannelTimetable,
64    HangupCause, ParseAnswerStateError, ParseCallDirectionError, ParseCallStateError,
65    ParseChannelStateError, ParseHangupCauseError, ParseTimetableError, TimetableField,
66    TimetablePrefix,
67};
68#[cfg(feature = "esl")]
69pub use commands::{
70    Application, BlockParse, BridgeDialString, BridgeDialStringDisplay, DialString,
71    DialStringCarrier, DialStringTarget, DialplanType, Endpoint, EndpointDisplay, ExecuteOn,
72    GroupCallOrder, Originate, OriginateDisplay, OriginateError, OriginateTarget,
73    ParseBlockParseError, ParseDialplanTypeError, ParseGroupCallOrderError, ParseHoldActionError,
74    ParseMuteActionError, UnvouchedVersion, UuidAnswer, UuidBridge, UuidDeflect, UuidGetVar,
75    UuidHold, UuidKill, UuidSendDtmf, UuidSetVar, UuidTransfer, Variables, VariablesDisplay,
76    VariablesType,
77};
78#[cfg(feature = "esl")]
79pub use event::{
80    EslEvent, EslEventPriority, EslEventType, EventFormat, EventSubscription,
81    EventSubscriptionError, ParseEventFormatError, ParseEventTypeError, ParsePriorityError,
82};
83pub use headers::{case_alias_key, normalize_header_key, EventHeader, ParseEventHeaderError};
84pub use log_level::{LogLevel, ParseLogLevelError};
85pub use lookup::{variable_key, HeaderLookup, ParseHeaderError};
86#[cfg(feature = "esl")]
87pub use lossy_values::{LossyValue, LossyValues};
88pub use sip_header::{
89    extract_header, HistoryInfo, HistoryInfoEntry, HistoryInfoError, HistoryInfoReason,
90    ParseSipHeaderAddrError, ParseSipHeaderError, SipGeolocation, SipGeolocationRef, SipHeader,
91    SipHeaderAddr, SipHeaderLookup, UriInfo, UriInfoEntry, UriInfoError,
92};
93pub use sofia::{
94    GatewayPingStatus, GatewayRegState, ParseGatewayPingStatusError, ParseGatewayRegStateError,
95    ParseSipUserPingStatusError, ParseSofiaEventSubclassError, SipUserPingStatus, SofiaChannelName,
96    SofiaEventSubclass,
97};
98#[cfg(feature = "esl")]
99pub use variables::EslHeaders;
100pub use variables::{
101    CarriedHeader, ChannelVariable, CoreMediaVariable, EslArray, EslArrayError, InvalidHeaderName,
102    MultipartBody, MultipartBodyError, MultipartItem, ParseChannelVariableError,
103    ParseCoreMediaVariableError, ParseSipPassthroughError, RtpStatUnit, SipHeaderPrefix,
104    SipPassthroughHeader, VariableName, MAX_ARRAY_ITEMS,
105};
106pub use version::{FreeswitchVersion, ParseFreeswitchVersionError};
107
108#[cfg(all(doctest, feature = "esl"))]
109mod readme {
110    #![doc = include_str!("../README.md")]
111}