Struct satrs::pool::StaticMemoryPool
source · pub struct StaticMemoryPool { /* private fields */ }
alloc
only.Expand description
Pool implementation providing sub-pools with fixed size memory blocks.
This is a simple memory pool implementation which pre-allocates all subpools using a given pool configuration. After the pre-allocation, no dynamic memory allocation will be performed during run-time. This makes the implementation suitable for real-time applications and embedded environments.
The subpool bucket sizes only denote the maximum possible data size being stored inside them and the pool implementation will still track the size of the data stored inside it. The implementation will generally determine the best fitting subpool for given data to add. Currently, the pool does not support spilling to larger subpools if the closest fitting subpool is full. This might be added in the future.
Transactions with the pool are done using a generic address type. Adding any data to the pool will yield a store address. Modification and read operations are done using a reference to a store address. Deletion will consume the store address.
Implementations§
source§impl StaticMemoryPool
impl StaticMemoryPool
sourcepub fn new(cfg: StaticPoolConfig) -> StaticMemoryPool
pub fn new(cfg: StaticPoolConfig) -> StaticMemoryPool
Create a new local pool from the given configuration. This function will sanitize the given configuration as well.
Trait Implementations§
source§impl PoolProvider for StaticMemoryPool
impl PoolProvider for StaticMemoryPool
source§fn add(&mut self, data: &[u8]) -> Result<PoolAddr, PoolError>
fn add(&mut self, data: &[u8]) -> Result<PoolAddr, PoolError>
source§fn free_element<W: FnMut(&mut [u8])>(
&mut self,
len: usize,
writer: W
) -> Result<PoolAddr, PoolError>
fn free_element<W: FnMut(&mut [u8])>( &mut self, len: usize, writer: W ) -> Result<PoolAddr, PoolError>
source§fn modify<U: FnMut(&mut [u8])>(
&mut self,
addr: &PoolAddr,
updater: U
) -> Result<(), PoolError>
fn modify<U: FnMut(&mut [u8])>( &mut self, addr: &PoolAddr, updater: U ) -> Result<(), PoolError>
source§fn read(&self, addr: &PoolAddr, buf: &mut [u8]) -> Result<usize, PoolError>
fn read(&self, addr: &PoolAddr, buf: &mut [u8]) -> Result<usize, PoolError>
source§fn delete(&mut self, addr: PoolAddr) -> Result<(), PoolError>
fn delete(&mut self, addr: PoolAddr) -> Result<(), PoolError>
fn has_element_at(&self, addr: &PoolAddr) -> Result<bool, PoolError>
source§fn len_of_data(&self, addr: &PoolAddr) -> Result<usize, PoolError>
fn len_of_data(&self, addr: &PoolAddr) -> Result<usize, PoolError>
fn read_as_vec(&self, addr: &PoolAddr) -> Result<Vec<u8>, PoolError>
source§impl PoolProviderWithGuards for StaticMemoryPool
impl PoolProviderWithGuards for StaticMemoryPool
source§fn modify_with_guard(&mut self, addr: PoolAddr) -> PoolRwGuard<'_, Self>
fn modify_with_guard(&mut self, addr: PoolAddr) -> PoolRwGuard<'_, Self>
source§fn read_with_guard(&mut self, addr: PoolAddr) -> PoolGuard<'_, Self>
fn read_with_guard(&mut self, addr: PoolAddr) -> PoolGuard<'_, Self>
Auto Trait Implementations§
impl Freeze for StaticMemoryPool
impl RefUnwindSafe for StaticMemoryPool
impl Send for StaticMemoryPool
impl Sync for StaticMemoryPool
impl Unpin for StaticMemoryPool
impl UnwindSafe for StaticMemoryPool
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.