Skip to main content

StagingBackend

Trait StagingBackend 

Source
pub trait StagingBackend:
    Debug
    + Send
    + Sync {
    // Required methods
    fn stage(&self, write: StagedWrite) -> bool;
    fn commit(&self) -> Result<CommitResult, Error>;
    fn rollback(&self);
    fn pending_count(&self) -> usize;
}
Expand description

Trait for staging write operations before committing to the filesystem.

Defined in brainwires-core so that ToolContext can hold an Arc<dyn StagingBackend> without depending on brainwires-tools, which would create a circular crate dependency.

The concrete implementation lives in brainwires-tools::transaction::TransactionManager.

Required Methods§

Source

fn stage(&self, write: StagedWrite) -> bool

Stage a write operation.

Returns true if newly staged, false if key was already present (idempotent — same key staged twice is a no-op).

Source

fn commit(&self) -> Result<CommitResult, Error>

Commit all staged writes to the filesystem.

Each staged file is moved (or copied) to its target path atomically. On success the staging queue is cleared.

Source

fn rollback(&self)

Discard all staged writes without touching the filesystem.

Source

fn pending_count(&self) -> usize

Return the number of pending staged writes.

Implementors§