1use std::collections::VecDeque;
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum TpktError {
7 #[error("TPKT Protocol Error - {}", .0)]
8 ProtocolError(String),
9
10 #[error("TPKT IO Error: {:?}", .0)]
11 IoError(#[from] std::io::Error),
12
13 #[error("TPKT Error: {}", .0)]
14 InternalError(String),
15}
16
17pub enum TpktRecvResult {
18 Closed,
19 Data(Vec<u8>),
20}
21
22pub trait TpktConnection: Send {
23 fn split(self) -> impl std::future::Future<Output = Result<(impl TpktReader, impl TpktWriter), TpktError>> + Send;
24}
25
26pub trait TpktReader: Send {
27 fn recv(&mut self) -> impl std::future::Future<Output = Result<TpktRecvResult, TpktError>> + Send;
28}
29
30pub trait TpktWriter: Send {
31 fn send(&mut self, input: &mut VecDeque<Vec<u8>>) -> impl std::future::Future<Output = Result<(), TpktError>> + Send;
32}