1use std::time;
2
3use o3::mem;
4
5use crate::{
6 engine::{Buffer, Source, register},
7 io::reactor::event,
8 table::token::host,
9};
10
11type Created<S, C, G, E> = (
12 <S as Source<C>>::Backend,
13 <<S as Source<C>>::Backend as Buffer>::Context,
14 <S as Create<C, G, E>>::Receive,
15);
16
17pub trait Register {
19 unsafe fn register(&mut self, source: register::Source<'_>) -> Result<(), register::Error>;
23}
24
25pub trait Poll {
27 type Context;
28 type Error: Copy + Eq;
29
30 unsafe fn wait<'a, Tag>(
33 &'a mut self,
34 quota: mem::raw::Shared<'_, Tag>,
35 timeout: Option<time::Duration>,
36 busy: bool,
37 ) -> Result<(), Self::Error>
38 where
39 Self::Context: 'a;
40}
41
42pub trait Create<C, G, E>: Source<C>
44where
45 Self::Backend: Buffer,
46{
47 type Receive;
48
49 unsafe fn try_new(config: &G) -> Result<Created<Self, C, G, E>, E>;
53}
54
55pub unsafe trait Owner<'d, N, F, D>
58where
59 F: host::raw::Drain + 'd,
60{
61 type Report: event::Report<Event = F::Reported>;
62
63 unsafe fn parts(
66 &mut self,
67 ) -> (
68 &mut N,
69 &'d F,
70 D,
71 &mut Self::Report,
72 &mut Option<register::Source<'d>>,
73 &mut bool,
74 );
75}