use std::time;
use o3::mem;
use crate::{
engine::{Buffer, Source, register},
io::reactor::event,
table::token::host,
};
type Created<S, C, G> = (
<S as Source<C>>::Backend,
<<S as Source<C>>::Backend as Buffer>::Context,
<S as Create<C, G>>::Receive,
);
pub trait Register {
unsafe fn register(&mut self, source: register::Source<'_>) -> Result<(), register::Error>;
}
pub trait Poll {
type Context;
type Error: Copy + Eq;
unsafe fn wait<'a, Tag>(
&'a mut self,
quota: mem::raw::Shared<'_, Tag>,
timeout: Option<time::Duration>,
busy: bool,
) -> Result<(), Self::Error>
where
Self::Context: 'a;
}
pub trait Create<C, G>: Source<C>
where
Self::Backend: Buffer,
{
type Receive;
type Error;
unsafe fn try_new(config: &G) -> Result<Created<Self, C, G>, Self::Error>;
}
pub unsafe trait Owner<'d, N, F, D>
where
F: host::raw::Drain + 'd,
{
type Report: event::Report<Event = F::Reported>;
unsafe fn parts(
&mut self,
) -> (
&mut N,
&'d F,
D,
&mut Self::Report,
&mut Option<register::Source<'d>>,
&mut bool,
);
}