Skip to main content

MemoryWriteHook

Trait MemoryWriteHook 

Source
pub trait MemoryWriteHook: Send + Sync {
    // Provided method
    fn before_write<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _chunk: &'life1 NewMemoryChunk,
    ) -> Pin<Box<dyn Future<Output = Result<WriteDecision>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

The hook providers consult before persisting a chunk.

Implementations must be cheap: this fires on every write through the memory subsystem. Keep implementations proportional to the number of rules or checks they evaluate.

Provided Methods§

Source

fn before_write<'life0, 'life1, 'async_trait>( &'life0 self, _chunk: &'life1 NewMemoryChunk, ) -> Pin<Box<dyn Future<Output = Result<WriteDecision>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decide what to do with the chunk. Default impl returns Allow, which makes wiring a hook optional — most consumers can ignore this trait entirely.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> MemoryWriteHook for ClosureHook<F>
where F: Fn(&NewMemoryChunk) -> WriteDecision + Send + Sync + 'static,