1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
//! ringline — async I/O runtime with io_uring and mio backends.
//!
//! ringline is a thread-per-core I/O framework with two compile-time
//! selectable backends: io_uring (Linux, default) and mio (cross-platform).
//! It provides an async/await API ([`AsyncEventHandler`]) on a single-threaded
//! executor with no work-stealing.
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use ringline::{AsyncEventHandler, Config, ConnCtx, ParseResult, RinglineBuilder};
//!
//! struct Echo;
//!
//! impl AsyncEventHandler for Echo {
//! fn on_accept(&self, conn: ConnCtx) -> impl std::future::Future<Output = ()> + 'static {
//! async move {
//! loop {
//! let n = conn.with_data(|data| {
//! conn.send_nowait(data).ok();
//! ParseResult::Consumed(data.len())
//! }).await;
//! if n == 0 { break; }
//! }
//! }
//! }
//! fn create_for_worker(_id: usize) -> Self { Echo }
//! }
//!
//! fn main() -> Result<(), ringline::Error> {
//! let config = Config::default();
//! let (_shutdown, handles) = RinglineBuilder::new(config)
//! .bind("127.0.0.1:7878".parse().unwrap())
//! .launch::<Echo>()?;
//! for h in handles { h.join().unwrap()?; }
//! Ok(())
//! }
//! ```
//!
//! # Platform
//!
//! With `io-uring` feature (default): Linux 6.0+. Requires io_uring with
//! multishot recv, ring-provided buffers, SendMsgZc, and fixed file table
//! support.
//!
//! With `--no-default-features`: mio backend, works on Linux and macOS.
//! NVMe passthrough and zero-copy sends are not available. Direct I/O and
//! filesystem operations are supported via a dedicated thread pool.
// ── Internal modules ────────────────────────────────────────────────────
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
// ── Backend detection ───────────────────────────────────────────────────
/// The I/O backend selected at compile time.
/// Returns the I/O backend selected at compile time.
// ── Public modules ──────────────────────────────────────────────────────
// ── Re-exports: Handler types ─────────────────────────────────────────
/// Peer address for a connection — TCP or Unix domain socket.
pub use PeerAddr;
/// Opaque connection handle.
pub use ConnToken;
/// I/O context passed to [`AsyncEventHandler::on_tick`] and [`AsyncEventHandler::on_notify`].
pub use DriverCtx;
/// Pre-classified part for scatter-gather sends via `submit_batch`.
pub use SendPart;
/// Opaque handle for a UDP socket.
pub use UdpToken;
// ── Re-exports: Async API ───────────────────────────────────────────────
/// Error returned by [`try_sleep()`] and [`try_timeout()`] when the timer pool is full.
pub use TimerExhausted;
/// Errors returned by UDP send operations.
pub use UdpSendError;
/// Trait for async event handlers (one task per connection).
pub use AsyncEventHandler;
/// Async scatter-gather send builder.
pub use AsyncSendBuilder;
/// Future returned by [`spawn_blocking()`]. Resolves to the closure's return value.
pub use BlockingJoinHandle;
/// Async connection context with send/recv futures.
pub use ConnCtx;
/// Future that completes when a connect finishes.
pub use ConnectFuture;
/// A monotonic clock deadline for absolute timers.
pub use Deadline;
/// Future that awaits a disk I/O completion (NVMe or Direct I/O).
pub use DiskIoFuture;
/// Error returned when a [`timeout()`] expires.
pub use Elapsed;
/// Handle to a spawned task's return value, obtained from [`spawn_with_handle()`].
pub use JoinHandle;
/// Result of a parse closure: consumed bytes or need more data.
pub use ParseResult;
/// Future that resolves when recv data is available (sink, accumulator, or close).
pub use RecvReadyFuture;
/// Future returned by [`resolve()`].
pub use ResolveFuture;
/// Future that completes when a send finishes.
pub use SendFuture;
/// Future returned by [`sleep()`].
pub use SleepFuture;
/// Future returned by [`timeout()`].
pub use TimeoutFuture;
/// Async context for a UDP socket.
pub use UdpCtx;
/// Future returned by [`UdpCtx::recv_from()`].
pub use UdpRecvFuture;
/// Future that provides received data as zero-copy `Bytes`.
pub use WithBytesFuture;
/// Future that provides received data.
pub use WithDataFuture;
/// Initiate an outbound TCP connection from any async task.
pub use connect;
/// Initiate an outbound TLS connection from any async task.
pub use connect_tls;
/// Initiate an outbound TLS connection with a timeout from any async task.
pub use connect_tls_with_timeout;
/// Initiate an outbound Unix domain socket connection from any async task.
pub use connect_unix;
/// Initiate an outbound TCP connection with a timeout from any async task.
pub use connect_with_timeout;
/// Submit a Direct I/O read and return a future for the result.
pub use direct_io_read;
/// Submit a Direct I/O write and return a future for the result.
pub use direct_io_write;
/// Submit an NVMe flush and return a future for the result.
pub use nvme_flush;
/// Submit an NVMe read and return a future for the result.
pub use nvme_read;
/// Submit an NVMe write and return a future for the result.
pub use nvme_write;
/// Open a Direct I/O file from any async task.
pub use open_direct_io_file;
/// Open an NVMe device from any async task.
pub use open_nvme_device;
/// Request graceful shutdown from any async task.
pub use request_shutdown;
/// Resolve a hostname to a `SocketAddr` using the dedicated resolver pool.
pub use resolve;
/// Create a future that completes after a duration.
pub use sleep;
/// Create a future that completes at an absolute deadline.
pub use sleep_until;
/// Spawn a standalone async task on the current worker.
pub use spawn;
/// Offload a blocking closure to the dedicated blocking thread pool.
pub use spawn_blocking;
/// Spawn a standalone async task and return a handle to await its result.
pub use spawn_with_handle;
/// Wrap a future with a deadline.
pub use timeout;
/// Wrap a future with an absolute deadline.
pub use timeout_at;
/// Fallible sleep that returns an error if the timer pool is exhausted.
pub use try_sleep;
/// Fallible sleep_until that returns an error if the timer pool is exhausted.
pub use try_sleep_until;
/// Fallible timeout that returns an error if the timer pool is exhausted.
pub use try_timeout;
/// Fallible timeout_at that returns an error if the timer pool is exhausted.
pub use try_timeout_at;
/// Future returned by [`join()`].
pub use Join;
/// Future returned by [`join3()`].
pub use Join3;
/// Poll two futures concurrently, returning both outputs when complete.
pub use join;
/// Poll three futures concurrently, returning all outputs when complete.
pub use join3;
/// Result of [`select()`] — which branch completed.
pub use Either;
/// Result of [`select3()`] — which branch completed.
pub use Either3;
/// Future returned by [`select()`].
pub use Select;
/// Future returned by [`select3()`].
pub use Select3;
/// Poll two futures concurrently, returning whichever completes first.
pub use select;
/// Poll three futures concurrently, returning whichever completes first.
pub use select3;
/// Opaque handle for a standalone spawned task.
pub use TaskId;
// ── Re-exports: Cancellation ────────────────────────────────────────────
/// Token for cooperative cancellation of async tasks.
pub use CancellationToken;
/// Future returned by [`CancellationToken::cancelled()`].
pub use CancelledFuture;
// ── Re-exports: Channels ────────────────────────────────────────────────
/// Error returned by [`oneshot::Receiver`] when the sender is dropped.
pub use RecvError;
/// Error returned by [`mpsc::Sender::send`] when the receiver is dropped.
pub use SendError;
/// Error returned by [`mpsc::Receiver::try_recv`].
pub use TryRecvError;
/// Error returned by [`mpsc::Sender::try_send`].
pub use TrySendError;
/// Bounded multi-producer, single-consumer async channel.
pub use mpsc;
/// Single-use async channel for sending exactly one value.
pub use oneshot;
// ── Re-exports: Signal handling ──────────────────────────────────────────
/// A caught signal (`SIGINT` or `SIGTERM`).
pub use Signal;
// ── Re-exports: Stream adapter ──────────────────────────────────────────
/// Wraps a [`ConnCtx`] and implements `futures_io::{AsyncRead, AsyncWrite, AsyncBufRead}`.
pub use ConnStream;
// ── Re-exports: Shared types ────────────────────────────────────────────
/// Memory region for io_uring fixed buffer registration.
pub use MemoryRegion;
/// Region identifier for [`SendGuard`] implementations.
pub use RegionId;
/// Maximum zero-copy guards per scatter-gather send.
pub use MAX_GUARDS;
/// Maximum iovecs per scatter-gather send.
pub use MAX_IOVECS;
/// Runtime configuration.
pub use Config;
/// Builder for [`Config`] with discoverable methods and `build()` validation.
pub use ConfigBuilder;
/// Recv buffer ring configuration.
pub use RecvBufferConfig;
/// Worker thread configuration.
pub use WorkerConfig;
/// Direct I/O completion result.
pub use DirectIoCompletion;
/// Direct I/O configuration.
pub use DirectIoConfig;
/// Direct I/O file handle.
pub use DirectIoFile;
/// Direct I/O operation type.
pub use DirectIoOp;
/// Runtime errors.
pub use Error;
/// Zero-copy send guard trait.
pub use ;
/// NVMe passthrough completion result.
pub use NvmeCompletion;
/// NVMe passthrough configuration.
pub use NvmeConfig;
/// NVMe passthrough device handle.
pub use NvmeDevice;
/// Builder for launching ringline workers.
pub use RinglineBuilder;
/// Handle for triggering graceful shutdown.
pub use ShutdownHandle;
// ── Re-exports: TLS ─────────────────────────────────────────────────────
/// Client-side TLS configuration.
pub use TlsClientConfig;
/// Server-side TLS configuration.
pub use TlsConfig;
/// TLS session info (protocol version, cipher suite, etc.).
pub use TlsInfo;