PoolProviderWithGuards

Trait PoolProviderWithGuards 

Source
pub trait PoolProviderWithGuards: PoolProvider {
    // Required methods
    fn read_with_guard(&mut self, addr: StoreAddr) -> PoolGuard<'_, Self>;
    fn modify_with_guard(&mut self, addr: StoreAddr) -> PoolRwGuard<'_, Self>;
}
Expand description

Extension trait which adds guarded pool access classes.

Required Methods§

Source

fn read_with_guard(&mut self, addr: StoreAddr) -> PoolGuard<'_, Self>

This function behaves like PoolProvider::read, but consumes the provided address and returns a RAII conformant guard object.

Unless the guard PoolRwGuard::release method is called, the data for the given address will be deleted automatically when the guard is dropped. This can prevent memory leaks. Users can read the data and release the guard if the data in the store is valid for further processing. If the data is faulty, no manual deletion is necessary when returning from a processing function prematurely.

Source

fn modify_with_guard(&mut self, addr: StoreAddr) -> PoolRwGuard<'_, Self>

This function behaves like PoolProvider::modify, but consumes the provided address and returns a RAII conformant guard object.

Unless the guard PoolRwGuard::release method is called, the data for the given address will be deleted automatically when the guard is dropped. This can prevent memory leaks. Users can read (and modify) the data and release the guard if the data in the store is valid for further processing. If the data is faulty, no manual deletion is necessary when returning from a processing function prematurely.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl PoolProviderWithGuards for StaticMemoryPool

Available on crate feature alloc only.