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