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> = (
12 <S as Source<C>>::Backend,
13 <<S as Source<C>>::Backend as Buffer>::Context,
14 <S as Create<C, G>>::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>: Source<C>
44where
45 Self::Backend: Buffer,
46{
47 type Receive;
48 type Error;
49
50 unsafe fn try_new(config: &G) -> Result<Created<Self, C, G>, Self::Error>;
54}
55
56pub unsafe trait Owner<'d, N, F, D>
59where
60 F: host::raw::Drain + 'd,
61{
62 type Report: event::Report<Event = F::Reported>;
63
64 unsafe fn parts(
67 &mut self,
68 ) -> (
69 &mut N,
70 &'d F,
71 D,
72 &mut Self::Report,
73 &mut Option<register::Source<'d>>,
74 &mut bool,
75 );
76}