freeswitch-types
FreeSWITCH protocol types: channel state, events, headers, command builders, and variable parsers. No async runtime dependency.
Use this crate standalone for CDR parsing, config generation, command building, or channel variable validation without pulling in tokio.
For async ESL transport (connecting to FreeSWITCH, sending commands, receiving
events), see freeswitch-esl-tokio
which re-exports everything from this crate.
What's included
| Module | Contents |
|---|---|
channel |
ChannelState, CallState, AnswerState, CallDirection, HangupCause, ChannelTimetable |
event |
EslEvent, EslEventType, EventFormat, EslEventPriority |
headers |
EventHeader enum (typed event header names) |
lookup |
HeaderLookup trait (typed accessors for any key-value store) |
commands |
Originate, BridgeDialString, UuidKill, UuidBridge, endpoint types, DialString trait |
variables |
ChannelVariable, SofiaVariable, EslArray, MultipartBody |
Features
serde(enabled by default) — addsSerialize/Deserializeimpls for all public types. Disable withdefault-features = falseif you only need wire-format parsing (Display/FromStr) without pulling in serde.
Usage
[]
= "1"
Without serde:
[]
= { = "1", = false }
Command builders
use Duration;
use *;
let cmd = application
.cid_name
.cid_num
.timeout;
// All builders implement Display, producing the FreeSWITCH wire format
assert!;
// All builders implement FromStr for round-trip parsing
let parsed: Originate = cmd.to_string.parse.unwrap;
assert_eq!;
Typed event accessors
use ;
// HeaderLookup works with any key-value store, not just EslEvent
;
// Now MyHeaders has all typed accessors:
// h.channel_state(), h.call_direction(), h.hangup_cause(),
// h.header(EventHeader::UniqueId), h.variable(ChannelVariable::ReadCodec), etc.
Serde support (requires serde feature, enabled by default)
All builder types implement Serialize/Deserialize for config-driven usage:
use Originate;
let json = r#"{
"endpoint": {"sofia_gateway": {"gateway": "carrier", "destination": "18005551234"}},
"application": {"name": "park"},
"timeout_secs": 30
}"#;
let cmd: Originate = from_str.unwrap;
println!;
Variable parsers
use ;
let arr = parse.unwrap;
assert_eq!;
Relationship to freeswitch-esl-tokio
This crate contains all domain types extracted from the
freeswitch-esl-tokio
workspace. The ESL crate re-exports everything, so users of freeswitch-esl-tokio
don't need to depend on this crate directly.
Depend on freeswitch-types directly when you need FreeSWITCH types without
async transport (CDR processors, config validators, CLI tools, test harnesses).
License
MIT OR Apache-2.0