freeswitch_esl/
esl.rs

1use tokio::net::ToSocketAddrs;
2
3use crate::{connection::EslConnection, outbound::Outbound, EslError};
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub(crate) enum EslConnectionType {
6    Inbound,
7    Outbound,
8}
9/// Esl struct with inbound and outbound method.
10pub struct Esl;
11impl Esl {
12    /// Creates new inbound connection to freeswitch
13    pub async fn inbound(
14        addr: impl ToSocketAddrs,
15        password: impl ToString,
16    ) -> Result<EslConnection, EslError> {
17        EslConnection::new(addr, password, EslConnectionType::Inbound).await
18    }
19
20    /// Creates new server for outbound connection
21    pub async fn outbound(addr: impl ToSocketAddrs) -> Result<Outbound, EslError> {
22        Outbound::bind(addr).await
23    }
24}