use super::Endpoint;
use std::error::Error;
pub trait Reader<E: Endpoint>: Send + Sync {
type Error: Error;
fn read(&self, buf: &mut [u8]) -> Result<(usize, E), Self::Error>;
}
pub trait Writer<E: Endpoint>: Send + Sync + 'static {
type Error: Error;
fn write(&self, buf: &[u8], dst: &mut E) -> Result<(), Self::Error>;
}
pub trait UDP: Send + Sync + 'static {
type Error: Error;
type Endpoint: Endpoint;
type Writer: Writer<Self::Endpoint>;
type Reader: Reader<Self::Endpoint>;
}
pub trait Owner: Send {
type Error: Error;
fn get_port(&self) -> u16;
fn set_fwmark(&mut self, value: Option<u32>) -> Result<(), Self::Error>;
}
pub trait PlatformUDP: UDP {
type Owner: Owner;
#[allow(clippy::type_complexity)]
fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>;
}