Skip to main content

dope_sys/ring/create/
mod.rs

1mod acquire;
2mod build;
3mod cause;
4mod error;
5mod failure;
6mod primary;
7mod retain;
8pub use acquire::Acquire;
9pub use build::Build;
10pub use cause::Cause;
11pub use error::Error;
12pub use failure::Failure;
13use o3::base::num::bounded;
14pub use primary::Primary;
15pub use retain::Retain;
16
17use crate::{
18    io::{Close, reactor::complete},
19    memory,
20    memory::buffer::provided,
21    probe, ring,
22    ring::{map, ready},
23    table::token,
24};
25
26type Creation<S> = Error<<S as Create>::Setup, <S as Create>::Map, <S as Create>::Cleanup>;
27
28/// Selects the native owner of every partially constructed reactor resource.
29pub trait Source: probe::Source + provided::Source {
30    type Primary: Copy;
31    type Failure<T: token::Codec>
32    where
33        Self: complete::Observe<T>;
34    type Resources<T: token::Codec, L: memory::raw::Canary, P: Copy + From<Self::Primary> + From<memory::Error>>: Retain<
35            P,
36            Error = <Self as Source>::Failure<T>,
37            Ring = Self::Ring<T>,
38            Probe = <Self as probe::Source>::Cleanup<T, L, P>,
39            Canary = Self::Canary<L>,
40            Context = Self::Context<L>,
41            Buffers = <Self as provided::Source>::Cleanup<L>,
42            Producer = Self::Producer<L>,
43            Registration = <Self::Ring<T> as ring::Owner>::Registration,
44            Registered = <Self::Ring<T> as ring::Owner>::Registered,
45            BufferError = <Self::Ready<T, L> as ready::Ready>::BufferError,
46        >
47    where
48        Self: complete::Observe<T>;
49}
50
51/// Creates a single-issuer ring with the requested queue capacities.
52pub trait Create: Close + Sized {
53    type Setup: Copy;
54    type Map: Copy;
55    type Unmap;
56    type Cleanup: memory::Cleanup<Cause<Self::Setup, Self::Map>, Error = map::Failure<Self::Unmap>>;
57
58    fn new<const MIN: u32, const MAX: u32, const CQ: u32>(
59        submit: bounded::U32<MIN, MAX>,
60        complete: bounded::U32<1, CQ>,
61        defer: bool,
62    ) -> Result<Self, Creation<Self>>;
63}