Skip to main content

freeswitch_types/
lib.rs

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