Skip to main content

MemWriter

Trait MemWriter 

Source
pub trait MemWriter: Send + Sync {
    // Required methods
    fn write_entity(
        &self,
        rel_path: &Path,
        content: &[u8],
    ) -> Result<(), MemWriterError>;
    fn delete_entity(&self, rel_path: &Path) -> Result<(), MemWriterError>;
    fn move_entity(&self, from: &Path, to: &Path) -> Result<(), MemWriterError>;
    fn commit(
        &self,
        message: &str,
        ctx: &CommitContext<'_>,
    ) -> Result<String, MemWriterError>;
}
Expand description

Write-side abstraction for mem content. Implementations are Send + Sync so the engine can hold a Box<dyn MemWriter> on each MemState and reach it from any caller.

Required Methods§

Source

fn write_entity( &self, rel_path: &Path, content: &[u8], ) -> Result<(), MemWriterError>

Upsert content at rel_path (mem-relative). Pending until Self::commit.

Source

fn delete_entity(&self, rel_path: &Path) -> Result<(), MemWriterError>

Remove rel_path (mem-relative). Idempotent: no-op when the path is already absent. Pending until Self::commit.

Source

fn move_entity(&self, from: &Path, to: &Path) -> Result<(), MemWriterError>

Rename from to to (both mem-relative). Pending until Self::commit. Errors if to already exists.

Source

fn commit( &self, message: &str, ctx: &CommitContext<'_>, ) -> Result<String, MemWriterError>

Flush pending mutations into a single commit. The implementation picks up the actor / committer / trailer information from ctx. Returns the resulting CommitId (opaque; the git-tree adapter formats it as a hex object id).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§