Skip to main content

pigeonhole_io/
lib.rs

1//! Vfs abstraction for Pigeonhole: files, aligned buffers, completions, pread pool and
2//! fault-injecting simulated backend.
3//!
4//! Every byte any other crate reads or writes goes through a [`Vfs`], so the simulator can
5//! inject faults and control time. Backends:
6//!
7//! - [`pread::PreadVfs`]: real files, a `pread`/`pwrite` thread pool for submitted I/O. The
8//!   safe reference backend on every platform.
9//! - [`sim::SimVfs`]: in-memory, deterministic from a seed, with torn writes, reordered
10//!   fsyncs, ENOSPC and crashes. With [`sim::FaultPlan::none`] it is the plain in-memory mock
11//!   other crates test against.
12//! - `uring::UringVfs` (Linux only, so not linked here): real files with submitted I/O on
13//!   io_uring (#402).
14//!
15//! This crate also owns the other OS-facing `unsafe` the engine needs: shared-memory mappings
16//! ([`SharedRegion`]), byte-range locks, thread pinning and NUMA binding ([`sys`]).
17//!
18//! Part of [Pigeonhole](https://github.com/CodingAnarchy/pigeonhole). See the crate README.
19// `unsafe` is permitted in this crate; every block carries a `// SAFETY:` argument.
20#![deny(unsafe_op_in_unsafe_fn)]
21
22mod async_poll;
23mod buf;
24mod completion;
25mod count;
26mod error;
27mod file;
28mod nowait;
29mod os;
30mod own;
31pub mod pread;
32#[cfg(any(target_os = "linux", io_loom))]
33mod ring_wake;
34mod shared;
35pub mod sim;
36pub mod sys;
37#[cfg(target_os = "linux")]
38pub mod uring;
39mod vfs;
40
41#[doc(hidden)]
42pub use async_poll::{
43    AsyncPollScope, async_poll_scope, in_async_poll, note_thread_file_read, thread_file_reads,
44};
45pub use buf::{BufPool, IoBuf};
46pub use completion::{Completion, Resolver};
47pub use count::IoCounters;
48pub use error::{Error, ErrorKind, Result};
49pub use file::{File, FileRef, Locality, LockMode, OpenOptions};
50#[doc(hidden)]
51pub use nowait::{MISS_BUCKETS, NowaitReads};
52pub use own::{
53    OwnIoWaker, in_inline_io, inline_io, own_io_enters, own_io_fd, own_io_in_flight, own_io_waker,
54    reap_orphan_io, reap_own_io,
55};
56pub use shared::{SharedOpen, SharedRegion};
57pub use vfs::{FileIdentity, ProcessId, RingStats, Vfs, VfsRef};