fswtch-sys 0.1.1

Rust bindings and helpers for writing FreeSWITCH modules
Documentation

fswtch

Rust bindings for writing FreeSWITCH modules.

This workspace is split into two crates:

  • fswtch-sys: raw FreeSWITCH ABI bindings. By default it exposes a small handwritten module ABI that builds without a configured FreeSWITCH source tree. Enable the bindgen feature to generate broader bindings from switch.h.
  • fswtch: higher-level helpers for module exports, module interface creation, API command registration, and stream writes.
  • fswtch-src: vendored FreeSWITCH headers used by fswtch-sys when the bundled feature is enabled.

Header Discovery

For generated bindings, point the build at configured FreeSWITCH headers:

FREESWITCH_INCLUDE_DIR=/usr/include/freeswitch cargo check -p fswtch-sys --features bindgen

If FreeSWITCH is installed with pkg-config, fswtch-sys will also try the freeswitch package for link metadata. You can override linking with:

FREESWITCH_LIB_DIR=/usr/lib/freeswitch cargo build

The vendored freeswitch/ tree is useful source context, but it does not include generated config headers until FreeSWITCH has been configured.

The bundled feature enables bindgen and points it at the packaged fswtch-src vendored headers:

cargo check -p fswtch-sys --features bundled
cargo check -p fswtch --features bundled

This feature is for generating Rust bindings from the vendored headers. It does not compile or statically link FreeSWITCH itself.

Publishing

Publish crates in dependency order:

cargo publish -p fswtch-src
cargo publish -p fswtch-sys
cargo publish -p fswtch

For dry-runs before the first upload of a new version, fswtch-sys and fswtch will not fully resolve until their registry dependencies already exist. Start by dry-running and publishing fswtch-src.

Module Skeleton

See crates/fswtch/examples/mod_hello.rs for the current Rust module shape:

fswtch::module_exports! {
    module = mod_hello,
    load = switch_module_load,
}

Inside switch_module_load, create a Module from the raw FreeSWITCH load arguments and register APIs with Module::add_api.