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
//! Filesystem abstraction.
//!
//! [`Env`] is the trait every filesystem-touching code path takes
//! generically. Two impls ship:
//!
//! - [`StdEnv`] — backed by `std::fs`. Production path.
//! - [`MemEnv`] — fully in-memory. Used by every test in this crate
//! so they don't need a temp dir.
//!
//! # Trait shape
//!
//! ```text
//! pub trait Env: Send + Sync {
//! type Writable: WritableFile;
//! type RandomAccess: RandomAccessFile;
//! type Sequential: SequentialFile;
//! type Lock: /* opaque */;
//!
//! fn new_writable_file(&self, path: &Path) -> Result<Self::Writable>;
//! fn new_random_access_file(&self, path: &Path) -> Result<Self::RandomAccess>;
//! fn new_sequential_file(&self, path: &Path) -> Result<Self::Sequential>;
//! fn lock_file(&self, path: &Path) -> Result<Self::Lock>;
//! fn read_file(&self, path: &Path) -> Result<Vec<u8>>;
//! fn write_file(&self, path: &Path, data: &[u8]) -> Result<()>;
//! fn append_file(&self, path: &Path, data: &[u8]) -> Result<()>;
//! fn file_exists(&self, path: &Path) -> bool;
//! fn delete_file(&self, path: &Path) -> Result<()>;
//! fn rename_file(&self, src: &Path, dst: &Path) -> Result<()>;
//! fn get_file_size(&self, path: &Path) -> Result<u64>;
//! fn list_dir(&self, path: &Path) -> Result<Vec<PathBuf>>;
//! fn create_dir(&self, path: &Path) -> Result<()>;
//! fn sync_file(&self, path: &Path) -> Result<()>;
//! fn delete_dir(&self, path: &Path) -> Result<()>;
//! }
//! ```
//!
//! # Custom Env
//!
//! Implementations are free to back files however they like —
//! S3 blobs, encrypted volumes, fault-injection wrappers, etc.
//! The trait is `Send + Sync`; every method takes `&self`.
//!
//! Most fault-injection tests in this crate use this pattern — see
//! `tests/generated_bg_error_propagation.rs` for a working
//! `FaultEnv` that forwards everything to an inner `MemEnv` while
//! letting tests inject failures on specific paths.
//!
//! # File-handle traits
//!
//! - [`WritableFile`] — `append`, `flush`, `sync`, `close`. Buffered
//! writes; `sync` forces durability.
//! - [`RandomAccessFile`] — `read_at(offset, n)`. Used by Table.
//! - [`SequentialFile`] — `read(n)`, `skip(n)`. Used by log/manifest.
pub use *;