use std::future::Future;
use std::pin::Pin;
use crate::{EncodeCtx, Frame, FrameView, TransportError};
pub trait Transport: Send + Sync {
fn send_frame(&self, frame: &Frame) -> impl Future<Output = Result<(), TransportError>> + Send;
fn recv_frame(&self) -> impl Future<Output = Result<FrameView<'_>, TransportError>> + Send;
fn encoder(&self) -> Box<dyn EncodeCtx + '_>;
fn close(&self) -> impl Future<Output = Result<(), TransportError>> + Send;
}
pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
pub trait DynTransport: Send + Sync {
fn send_frame_boxed(&self, frame: &Frame) -> BoxFuture<'_, Result<(), TransportError>>;
fn recv_frame_boxed(&self) -> BoxFuture<'_, Result<Frame, TransportError>>;
fn encoder_boxed(&self) -> Box<dyn EncodeCtx + '_>;
fn close_boxed(&self) -> BoxFuture<'_, Result<(), TransportError>>;
}