Skip to main content

RwImage

Struct RwImage 

Source
pub struct RwImage { /* private fields */ }
Expand description

An open read-write LimniFS image.

Implementations§

Source§

impl RwImage

Source

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.

Source

pub fn create_new(path: &Path, config: WriteConfig) -> Self

Create a new empty RW image. The first commit produces the on-disk manifest + slabs.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn pending_changes(&self) -> usize

Number of pending (uncommitted) changes.

Source

pub fn needs_turnover(&self) -> bool

Check if auto-turnover should trigger based on the config’s turnover_threshold.

Source

pub fn mode(&self) -> &ImageMode

Get the image mode (RO vs RW sub-mode).

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.