pub mod frame_codec;
#[cfg(any(feature = "actix-web", feature = "ntex"))]
pub mod bridge;
#[cfg(feature = "actix-web")]
pub mod actix;
#[cfg(feature = "axum")]
pub mod axum;
#[cfg(feature = "ntex")]
pub mod ntex;
#[cfg(feature = "warp")]
pub mod warp;
#[cfg(feature = "websocket")]
pub mod websocket;
use async_trait::async_trait;
use std::net::SocketAddr;
use crate::error::Result;
use crate::frame::Frame;
use crate::protocol::close::CloseCode;
#[async_trait]
pub trait Transport: Send + Sync {
async fn bind(&self, addr: SocketAddr) -> Result<Box<dyn TransportListener>>;
fn name(&self) -> &'static str;
}
#[async_trait]
pub trait TransportListener: Send {
async fn accept(&mut self) -> Result<Box<dyn TransportConnection>>;
fn local_addr(&self) -> Result<SocketAddr>;
}
#[async_trait]
pub trait TransportConnection: Send {
async fn read_frame(&mut self) -> Result<Frame>;
async fn write_frame(&mut self, frame: &Frame) -> Result<()>;
async fn close(&mut self, code: CloseCode, reason: &str) -> Result<()>;
fn peer_addr(&self) -> Option<SocketAddr>;
}