Skip to main content

dope_core/
lib.rs

1//! Ownership and lifetime contracts.
2
3pub mod driver;
4pub mod io;
5pub mod platform;
6pub mod random;
7
8pub use dope_sys::{self, Errno};
9use dope_sys::{
10    engine::{Removal, Source, Storage},
11    table::permit,
12};
13use driver::{
14    life::native::{create, host::Host},
15    receive,
16    result::{IoOperation, Kernel},
17    schedule::ready::Stored,
18};
19pub use o3;
20
21type Engine = <Backend as Source<Host<Backend>>>::Backend;
22type Events = <Backend as Source<Host<Backend>>>::Map;
23type Resources =
24    <Backend as Storage<Host<Backend>, create::Failure, (IoOperation, Kernel)>>::Cleanup;
25type Released =
26    <Backend as Storage<Host<Backend>, create::Failure, (IoOperation, Kernel)>>::Release;
27type RemoveSlot = <Backend as Removal>::Slot;
28type Permits = <Backend as permit::Source>::Queue<Stored, receive::Index>;
29
30/// Failure from the first or second branch of a statically composed operation.
31#[derive(Debug)]
32pub enum BranchError<A, B> {
33    /// The first branch failed.
34    First(A),
35    /// The second branch failed.
36    Second(B),
37}
38
39cfg_select! {
40    target_os = "linux" => {
41        pub type Backend = dope_uring::Uring;
42        mod ring;
43        use ring as completion;
44    }
45    target_os = "macos" => {
46        pub type Backend = dope_kqueue::Kqueue;
47        mod poll;
48        use poll as completion;
49    }
50}