use std::{any::Any, collections::VecDeque, fmt::Debug};
use dyn_clone::DynClone;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum TpktError {
#[error("TPKT Protocol Error - {}", .0)]
ProtocolError(String),
#[error("TPKT IO Error: {:?}", .0)]
IoError(#[from] std::io::Error),
#[error("TPKT Error: {}", .0)]
InternalError(String),
}
pub trait ProtocolInformation: Any + Send + Debug + DynClone {}
dyn_clone::clone_trait_object!(ProtocolInformation);
pub trait TpktConnection: Send {
fn get_protocol_infomation_list(&self) -> &Vec<Box<dyn ProtocolInformation>>;
fn split(self) -> impl std::future::Future<Output = Result<(impl TpktReader, impl TpktWriter), TpktError>> + Send;
}
pub trait TpktReader: Send {
fn recv(&mut self) -> impl std::future::Future<Output = Result<Option<Vec<u8>>, TpktError>> + Send;
}
pub trait TpktWriter: Send {
fn send(&mut self, input: &mut VecDeque<Vec<u8>>) -> impl std::future::Future<Output = Result<(), TpktError>> + Send;
}