pub struct ClosureHook<F>(pub F)
where
F: Fn(&NewMemoryChunk) -> WriteDecision + Send + Sync + 'static;Expand description
Convenience wrapper for callers that want to plug a closure in without declaring a struct. Useful for tests, examples, and small policy adapters.
Tuple Fields§
§0: FTrait Implementations§
Source§impl<F> MemoryWriteHook for ClosureHook<F>
impl<F> MemoryWriteHook for ClosureHook<F>
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,
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.Auto Trait Implementations§
impl<F> Freeze for ClosureHook<F>where
F: Freeze,
impl<F> RefUnwindSafe for ClosureHook<F>where
F: RefUnwindSafe,
impl<F> Send for ClosureHook<F>
impl<F> Sync for ClosureHook<F>
impl<F> Unpin for ClosureHook<F>where
F: Unpin,
impl<F> UnsafeUnpin for ClosureHook<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ClosureHook<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more