Skip to content

Commit

Permalink
removed outbound struct from public api
Browse files Browse the repository at this point in the history
  • Loading branch information
KaranGauswami committed Sep 13, 2023
1 parent d82f378 commit 2a0cd44
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ async fn main() -> Result<(), EslError> {
let addr = "0.0.0.0:8085"; // Listening address
println!("Listening on {}", addr);
let listener = TcpListener::bind(addr).await?;
let listener = Esl::outbound(listener).await?;

loop {
let (socket, _) = listener.accept().await?;
let socket = Esl::outbound(socket).await?;
tokio::spawn(async move { process_call(socket).await });
}
}
10 changes: 6 additions & 4 deletions src/esl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tokio::net::{TcpListener, ToSocketAddrs};
use tokio::net::{TcpStream, ToSocketAddrs};

use crate::{connection::EslConnection, outbound::Outbound, EslError};
use crate::{connection::EslConnection, EslError};
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum EslConnectionType {
Inbound,
Expand All @@ -18,7 +18,9 @@ impl Esl {
}

/// Creates new server for outbound connection
pub async fn outbound(listener: TcpListener) -> Result<Outbound, EslError> {
Outbound::new(listener).await
pub async fn outbound(stream: TcpStream) -> Result<EslConnection, EslError> {
let connection =
EslConnection::with_tcpstream(stream, "None", EslConnectionType::Outbound).await?;
Ok(connection)
}
}
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
//! let addr = "0.0.0.0:8085"; // Listening address
//! println!("Listening on {}", addr);
//! let listener = TcpListener::bind(addr).await?;
//! let server = Esl::outbound(listener).await?;
//!
//! loop {
//! let (socket, _) = server.accept().await?;
//! let (socket, _) = listener.accept().await?;
//! let socket = Esl::outbound(socket).await?;
//! tokio::spawn(async move { process_call(socket).await });
//! }
//! }
Expand All @@ -73,7 +73,6 @@ pub(crate) mod error;
pub(crate) mod esl;
pub(crate) mod event;
pub(crate) mod io;
pub(crate) mod outbound;

pub use connection::EslConnection;
pub use error::*;
Expand Down
20 changes: 0 additions & 20 deletions src/outbound.rs

This file was deleted.

0 comments on commit 2a0cd44

Please sign in to comment.