pub struct RwImage { /* private fields */ }Expand description
An open read-write LimniFS image.
Implementations§
Source§impl RwImage
impl RwImage
Sourcepub fn open(path: &Path, config: WriteConfig) -> Result<Self, WriteError>
pub fn open(path: &Path, config: WriteConfig) -> Result<Self, WriteError>
Open an existing image for read-write access. Parses the manifest, mmaps the slabs, and builds the path index.
§Errors
Returns WriteError if the manifest cannot be parsed or
the slab files cannot be opened.
Sourcepub fn create_new(path: &Path, config: WriteConfig) -> Self
pub fn create_new(path: &Path, config: WriteConfig) -> Self
Create a new empty RW image. The first commit produces the
on-disk manifest + slabs.
Sourcepub fn add_file(&mut self, path: &str, data: &[u8]) -> Result<u64, WriteError>
pub fn add_file(&mut self, path: &str, data: &[u8]) -> Result<u64, WriteError>
Add a new file to the image. The plaintext is staged for the
next commit; no I/O happens until then.
§Errors
Returns WriteError only if internal allocation fails.
Sourcepub fn update_file(&mut self, path: &str, data: &[u8]) -> Result<(), WriteError>
pub fn update_file(&mut self, path: &str, data: &[u8]) -> Result<(), WriteError>
Update an existing file. The old inode is marked superseded; old drops remain in slabs until the next turnover.
§Errors
Returns WriteError if the path doesn’t exist.
Sourcepub fn delete_file(&mut self, path: &str) -> Result<(), WriteError>
pub fn delete_file(&mut self, path: &str) -> Result<(), WriteError>
Delete a file. The inode is removed from the path index; old drops remain until the next turnover.
§Errors
Returns WriteError if the path doesn’t exist.
Sourcepub fn read_file(&self, path: &str) -> Result<Vec<u8>, WriteError>
pub fn read_file(&self, path: &str) -> Result<Vec<u8>, WriteError>
Read a file’s plaintext from the in-memory state. Only
available for images that have been opened.
§Errors
Returns WriteError if the image was not opened, the path
is unknown, or the slab is missing/corrupt.
Sourcepub fn pending_changes(&self) -> usize
pub fn pending_changes(&self) -> usize
Number of pending (uncommitted) changes.
Sourcepub fn needs_turnover(&self) -> bool
pub fn needs_turnover(&self) -> bool
Check if auto-turnover should trigger based on the config’s
turnover_threshold.
Sourcepub fn commit(&self) -> Result<WriteArtifact, WriteError>
pub fn commit(&self) -> Result<WriteArtifact, WriteError>
Commit pending changes. Materializes the live tree (if any), overlays pending writes, rebuilds the image with the configured codecs, and writes the new manifest + slabs.
Crash safety: writes the WAL with planned operations
before the manifest swap. If the swap is interrupted, the
WAL survives and is replayed on the next open, restoring
the user’s pending writes. On successful swap, the WAL is
unlinked.
§Errors
Returns WriteError on I/O or serialization failure.
Sourcepub fn turnover(&self) -> Result<WriteArtifact, WriteError>
pub fn turnover(&self) -> Result<WriteArtifact, WriteError>
Turnover: rebuild the current live tree with the configured codecs. Pending changes are dropped — this is a hygiene operation, not a commit.
§Errors
Returns WriteError on I/O or serialization failure.
Auto Trait Implementations§
impl Freeze for RwImage
impl RefUnwindSafe for RwImage
impl Send for RwImage
impl Sync for RwImage
impl Unpin for RwImage
impl UnsafeUnpin for RwImage
impl UnwindSafe for RwImage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more