pub trait FileBackend: Sized {
// Required methods
fn len(&self) -> Result<u64>;
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>;
fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>;
fn set_len(&self, new_len: u64) -> Result<()>;
fn sync_data(&self, mode: SyncMode) -> Result<()>;
fn sync_all(&self) -> Result<()>;
// Provided method
fn is_empty(&self) -> Result<bool> { ... }
}Expand description
File-backend abstraction the pager and WAL build on.
FileBackend is the common subset of FileHandle operations
that fault-injection harnesses and the production type both expose
(Rule 9). Production code never holds dyn FileBackend; both
crate::pager::Pager and crate::wal::Wal are generic over
F: FileBackend so the dispatch stays monomorphised.
New methods added to this trait MUST mirror an existing
FileHandle method exactly. Adding a method that does not exist
on the production type would let the harness perform syscalls
production code cannot — a forbidden divergence (the harness
must be a strict superset of legal behaviour, never a separate
kingdom).
Required Methods§
Sourcefn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
Positioned read. See FileHandle::read_exact_at.
§Errors
Returns Error::Io on syscall failure or harness-injected
short read.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".