dtact_util/lib.rs
1//! Async I/O, filesystem, process, signal, stream, and timer primitives for
2//! the `dtact` coroutine runtime.
3//!
4//! Two backend families are available behind Cargo features:
5//! - `native` — hand-rolled, lock-free backends (`io_uring` on Linux,
6//! kqueue/IOCP elsewhere, thread-pool bridges where a true async
7//! syscall path doesn't exist) built directly on `dtact`'s coroutine
8//! scheduler, no `tokio` dependency.
9//! - `tokio` (default) — thin wrappers over `tokio`'s equivalents, for
10//! embedding in a `tokio`-based application instead of `dtact` itself.
11//!
12//! Each of the six primitive modules (`io`, `fs`, `process`, `signal`,
13//! `stream`, `timer`) exposes the same public surface regardless of which
14//! backend feature is enabled, so callers can switch backends without
15//! rewriting call sites.
16
17// =========================================================================
18// RUST LINT CONFIGURATION: dtact-util
19// =========================================================================
20
21// -------------------------------------------------------------------------
22// LEVEL 1: CRITICAL ERRORS (Deny)
23// -------------------------------------------------------------------------
24#![deny(
25 unreachable_code,
26 improper_ctypes_definitions,
27 future_incompatible,
28 nonstandard_style,
29 rust_2018_idioms,
30 clippy::perf,
31 clippy::correctness,
32 clippy::suspicious,
33 clippy::unwrap_used,
34 clippy::expect_used,
35 clippy::indexing_slicing,
36 clippy::arithmetic_side_effects,
37 clippy::missing_safety_doc,
38 clippy::same_item_push,
39 clippy::implicit_clone,
40 clippy::all,
41 clippy::pedantic,
42 missing_docs,
43 clippy::nursery,
44 clippy::single_call_fn
45)]
46// -------------------------------------------------------------------------
47// LEVEL 2: STYLE WARNINGS (Warn)
48// -------------------------------------------------------------------------
49#![warn(
50 dead_code,
51 warnings,
52 clippy::dbg_macro,
53 clippy::todo,
54 clippy::unused_async,
55 clippy::cast_possible_truncation,
56 clippy::cast_sign_loss,
57 clippy::cast_possible_wrap,
58 clippy::unnecessary_safety_comment
59)]
60// -------------------------------------------------------------------------
61// LEVEL 3: ALLOW/IGNORABLE (Allow)
62// -------------------------------------------------------------------------
63#![allow(
64 unsafe_code,
65 unused_unsafe,
66 clippy::unused_async,
67 private_interfaces,
68 clippy::restriction,
69 clippy::inline_always,
70 unused_doc_comments,
71 clippy::empty_line_after_doc_comments,
72 clippy::missing_const_for_thread_local,
73 clippy::cast_possible_truncation,
74 clippy::cast_sign_loss,
75 clippy::cast_possible_wrap
76)]
77#![crate_name = "dtact_util"]
78
79#[cfg(feature = "native")]
80pub use dtact_macros::dtact_io_init as init;
81#[cfg(feature = "native")]
82pub use dtact_macros::fs_init;
83#[cfg(feature = "native")]
84pub use dtact_macros::process_init;
85
86// The Unix backend (io_uring on Linux, kqueue/mio elsewhere) is fd-based and
87// cannot compile on Windows; the Windows backend (`io::windows`, below) is
88// IOCP-based and cannot compile on Unix. Anything that's neither (e.g. wasm)
89// gets a clear build-time error instead of failing deep inside fd/handle code.
90#[cfg(all(feature = "native", not(any(unix, windows))))]
91compile_error!(
92 "dtact-util's `native` feature supports Unix (io_uring/kqueue) and \
93 Windows (IOCP) only. On other platforms, use the default `tokio` feature instead."
94);
95
96#[cfg(feature = "native")]
97pub mod lockfree;
98
99pub mod io;
100
101pub mod fs;
102
103pub mod timer;
104
105pub mod stream;
106
107pub mod signal;
108
109pub mod process;
110
111pub mod sync;
112
113#[cfg(feature = "ffi")]
114pub mod ffi;