FreeSwitch ESL implementation for Rust
```rust use freeswitch_esl::{Esl, EslError};
async fn main() -> Result<(), EslError> { let addr = "localhost:8021"; // Freeswitch host let password = "ClueCon"; let inbound = Esl::inbound(addr, password).await?;
let reloadxml = inbound.api("reloadxml").await?;
println!("reloadxml response : {:?}", reloadxml);
let reloadxml = inbound.bgapi("reloadxml").await?;
println!("reloadxml response : {:?}", reloadxml);
Ok(())
}
```
```rust use freeswitch_esl::{Esl, EslConnection, EslError};
async fn processcall(conn: EslConnection) -> Result<(), EslError> { conn.answer().await?; conn.playback("ivr/ivr-welcome.wav").await?; let digit = conn .playandgetdigits( 1, 1, 3, 3000, "#", "conference/conf-pin.wav", "conference/conf-bad-pin.wav", ) .await?; println!("got digit {}", digit); conn.playback("ivr/ivr-youentered.wav").await?; conn.playback(&format!("digits/{}.wav", digit)).await?; conn.hangup("NORMALCLEARING").await?; Ok(()) }
async fn main() -> Result<(), EslError> { env_logger::init(); let addr = "0.0.0.0:8085"; // Listening address let listener = Esl::outbound(addr).await?;
loop {
let (socket, _) = listener.accept().await?;
tokio::spawn(async move { process_call(socket).await });
}
}
```