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