1use crate::memory;
2pub mod create;
3pub mod enter;
4pub mod inspect;
5pub mod layout;
6pub mod map;
7pub mod prepare;
8pub mod ready;
9pub mod register;
10use self::{create::Create, enter::Enter, inspect::Inspect, map::Unmap, prepare::Prepare};
11use crate::{
12 io::{
13 Close,
14 reactor::{
15 complete,
16 complete::{Drain, Entry, message, packet::record},
17 submit,
18 },
19 },
20 kernel,
21 memory::buffer::provided,
22 probe::session::Closed,
23};
24
25pub trait Source: kernel::Source + Sized {
27 type Decoded<T: Copy, E>: record::Map<
28 Parts = complete::Parts<
29 T,
30 <Self::Entry<T> as Entry>::Outcome,
31 <Self::Entry<T> as Entry>::Flags,
32 >,
33 Fault = E,
34 >;
35 type Ready<T: complete::raw::Token, L: memory::raw::Receive>: ready::Ready<
36 Ring = Self::Ring<T>,
37 Token = T,
38 Layout = L,
39 Context = <Self as provided::Source>::Context<L>,
40 Producer = <Self as provided::Source>::Producer<L>,
41 Pending = <Self as provided::Source>::Pending<L::Extent>,
42 Index = <Self as provided::Source>::Index,
43 Entry = <Self as Source>::Entry<T>,
44 > + ready::raw::Create
45 where
46 Self: provided::Source;
47 type Poll: Copy + Eq;
48 type Entry<T>: complete::Entry<Token = T, Outcome: complete::Outcome<Returned = Self::Returned>>;
49 type Packet<T: Copy, B>: Packet<
50 Native = Self,
51 Parts = complete::Parts<
52 T,
53 <Self::Entry<T> as complete::Entry>::Outcome,
54 <Self::Entry<T> as complete::Entry>::Flags,
55 >,
56 Buffer = B,
57 >;
58 type Message<'a, const NAME: usize, const CONTROL: usize>: message::Output<'a>;
59 type Enter<'a, T: 'a>: Enter;
60 type Ring<T: complete::raw::Token>: Create
61 + Owner<Token = T>
62 + Prepare
63 + Inspect<Code = Self::Code>
64 + Complete<Entry = Self::Entry<T>>;
65}
66
67pub trait Packet: complete::Packet {
69 type Native: Source;
70}
71
72pub trait Access {
74 type Token;
75 type Target;
76 type File: register::Occupied<Target = Self::Target>;
77 type Queue<'a>: submit::Queue<'a, Self::Token>
78 where
79 Self: 'a,
80 Self::Token: complete::raw::Token;
81 type Enter<'a>: Enter
82 where
83 Self: 'a;
84 type Registry<'a>: register::Registry<Token = Self::Token, Target = Self::Target, File = Self::File>
85 where
86 Self: 'a;
87
88 fn sq(&mut self) -> Self::Queue<'_>
89 where
90 Self::Token: complete::raw::Token;
91 fn enter(&mut self) -> Self::Enter<'_>;
92 fn registry(&mut self) -> Self::Registry<'_>;
93}
94
95pub trait Owner: Access + Close<State: Unmap> + Sized {
97 type Registered: register::Registered<
98 Token = Self::Token,
99 State: map::Unmap<Error = <Self::State as map::Unmap>::Error>,
100 >;
101 type Registration: register::Registration;
102 type Closing: Closed<Target = Self::Target>;
103
104 fn try_register(self) -> Result<Self::Registered, Self::Registration>;
105 fn close_file(self, file: Self::File) -> Result<(), Self::Closing>;
106}
107
108pub trait Complete {
109 type Entry: Entry;
110 type Queue<'a>: Drain<Entry = Self::Entry>
111 where
112 Self: 'a;
113
114 fn completion(&mut self) -> Self::Queue<'_>;
115}