Skip to main content

dope_sys/ring/
mod.rs

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},
17            submit,
18        },
19    },
20    kernel,
21    memory::buffer::provided,
22    probe::session::Closed,
23};
24
25/// Native ring ownership specialized to the caller's completion token.
26pub trait Source: kernel::Source + Sized {
27    type Ready<T: complete::raw::Token, L: memory::raw::Receive>: ready::Ready<
28            Ring = Self::Ring<T>,
29            Token = T,
30            Layout = L,
31            Context = <Self as provided::Source>::Context<L>,
32            Producer = <Self as provided::Source>::Producer<L>,
33            Entry = <Self as Source>::Entry<T>,
34        > + ready::raw::Create
35    where
36        Self: provided::Source;
37    type Poll: Copy + Eq;
38    type Entry<T>: complete::Entry<Token = T, Outcome: complete::Outcome<Returned = Self::Returned>>;
39    type Message<'a, const NAME: usize, const CONTROL: usize>: message::Output<'a>;
40    type Enter<'a, T: 'a>: Enter;
41    type Ring<T: complete::raw::Token>: Create
42        + Owner<Token = T>
43        + Prepare
44        + Inspect<Code = Self::Code>
45        + Complete<Entry = Self::Entry<T>>;
46}
47
48/// Exclusive queue and registration views borrow the same native owner.
49pub trait Access {
50    type Token;
51    type Target;
52    type File: register::Occupied<Target = Self::Target>;
53    type Queue<'a>: submit::Queue<'a, Self::Token>
54    where
55        Self: 'a,
56        Self::Token: complete::raw::Token;
57    type Enter<'a>: Enter
58    where
59        Self: 'a;
60    type Registry<'a>: register::Registry<Token = Self::Token, Target = Self::Target, File = Self::File>
61    where
62        Self: 'a;
63
64    fn sq(&mut self) -> Self::Queue<'_>
65    where
66        Self::Token: complete::raw::Token;
67    fn enter(&mut self) -> Self::Enter<'_>;
68    fn registry(&mut self) -> Self::Registry<'_>;
69}
70
71/// Ring registration and failed fixed-file cleanup retain the complete owner.
72pub trait Owner: Access + Close<State: Unmap> + Sized {
73    type Registered: register::Registered<
74            Token = Self::Token,
75            State: map::Unmap<Error = <Self::State as map::Unmap>::Error>,
76        >;
77    type Registration: register::Registration;
78    type Closing: Closed<Target = Self::Target>;
79
80    fn try_register(self) -> Result<Self::Registered, Self::Registration>;
81    fn close_file(self, file: Self::File) -> Result<(), Self::Closing>;
82}
83
84pub trait Complete {
85    type Entry: Entry;
86    type Queue<'a>: Drain<Entry = Self::Entry>
87    where
88        Self: 'a;
89
90    fn completion(&mut self) -> Self::Queue<'_>;
91}