Skip to main content

JournalingObject

Trait JournalingObject 

Source
pub trait JournalingObject: Send + Sync {
    // Required methods
    fn apply_mutation(
        &self,
        mutation: Mutation,
        context: &ApplyContext<'_, '_>,
        assoc_obj: AssocObj<'_>,
    ) -> Result<(), Error>;
    fn drop_mutation(&self, mutation: Mutation, transaction: &Transaction<'_>);
    fn flush<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Version, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn prepare_commit<'a, 'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _filesystem: &'a FxFilesystem,
        _transaction: &'life1 Transaction<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<WriteGuard<'a>>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn write_mutation(&self, mutation: &Mutation, writer: Writer<'_>) { ... }
}
Expand description

Objects that use journaling to track mutations (Allocator and ObjectStore) implement this. This is primarily used by ObjectManager and SuperBlock with flush calls used in a few tests.

Required Methods§

Source

fn apply_mutation( &self, mutation: Mutation, context: &ApplyContext<'_, '_>, assoc_obj: AssocObj<'_>, ) -> Result<(), Error>

This method get called when the transaction commits, which can either be during live operation (See ObjectManager::apply_mutation) or during journal replay, in which case transaction will be None (See super_block::read).

Source

fn drop_mutation(&self, mutation: Mutation, transaction: &Transaction<'_>)

Called when a transaction fails to commit.

Source

fn flush<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Version, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Flushes in-memory changes to the device (to allow journal space to be freed).

Also returns the earliest version of a struct in the filesystem.

Provided Methods§

Source

fn prepare_commit<'a, 'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _filesystem: &'a FxFilesystem, _transaction: &'life1 Transaction<'life2>, ) -> Pin<Box<dyn Future<Output = Result<Option<WriteGuard<'a>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Called before committing a transaction. Implementations can use this to acquire locks or resources (like keys) that must be held until the transaction is committed.

Source

fn write_mutation(&self, mutation: &Mutation, writer: Writer<'_>)

Writes a mutation to the journal. This allows objects to encrypt or otherwise modify what gets written to the journal.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§