This commit is contained in:
parent
269324de28
commit
a077c32f3c
@ -217,14 +217,14 @@ impl Error for PoolError {
|
|||||||
/// pool structure being wrapped inside a lock.
|
/// pool structure being wrapped inside a lock.
|
||||||
pub trait PoolProvider {
|
pub trait PoolProvider {
|
||||||
/// Add new data to the pool. The provider should attempt to reserve a memory block with the
|
/// Add new data to the pool. The provider should attempt to reserve a memory block with the
|
||||||
/// appropriate size and then copy the given data to the block. Yields a [StoreAddr] which can
|
/// appropriate size and then copy the given data to the block. Yields a [PoolAddr] which can
|
||||||
/// be used to access the data stored in the pool
|
/// be used to access the data stored in the pool
|
||||||
fn add(&mut self, data: &[u8]) -> Result<PoolAddr, PoolError>;
|
fn add(&mut self, data: &[u8]) -> Result<PoolAddr, PoolError>;
|
||||||
|
|
||||||
/// The provider should attempt to reserve a free memory block with the appropriate size first.
|
/// The provider should attempt to reserve a free memory block with the appropriate size first.
|
||||||
/// It then executes a user-provided closure and passes a mutable reference to that memory
|
/// It then executes a user-provided closure and passes a mutable reference to that memory
|
||||||
/// block to the closure. This allows the user to write data to the memory block.
|
/// block to the closure. This allows the user to write data to the memory block.
|
||||||
/// The function should yield a [StoreAddr] which can be used to access the data stored in the
|
/// The function should yield a [PoolAddr] which can be used to access the data stored in the
|
||||||
/// pool.
|
/// pool.
|
||||||
fn free_element<W: FnMut(&mut [u8])>(
|
fn free_element<W: FnMut(&mut [u8])>(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -232,7 +232,7 @@ pub trait PoolProvider {
|
|||||||
writer: W,
|
writer: W,
|
||||||
) -> Result<PoolAddr, PoolError>;
|
) -> Result<PoolAddr, PoolError>;
|
||||||
|
|
||||||
/// Modify data added previously using a given [StoreAddr]. The provider should use the store
|
/// Modify data added previously using a given [PoolAddr]. The provider should use the store
|
||||||
/// address to determine if a memory block exists for that address. If it does, it should
|
/// address to determine if a memory block exists for that address. If it does, it should
|
||||||
/// call the user-provided closure and pass a mutable reference to the memory block
|
/// call the user-provided closure and pass a mutable reference to the memory block
|
||||||
/// to the closure. This allows the user to modify the memory block.
|
/// to the closure. This allows the user to modify the memory block.
|
||||||
@ -243,7 +243,7 @@ pub trait PoolProvider {
|
|||||||
/// it exists.
|
/// it exists.
|
||||||
fn read(&self, addr: &PoolAddr, buf: &mut [u8]) -> Result<usize, PoolError>;
|
fn read(&self, addr: &PoolAddr, buf: &mut [u8]) -> Result<usize, PoolError>;
|
||||||
|
|
||||||
/// Delete data inside the pool given a [StoreAddr].
|
/// Delete data inside the pool given a [PoolAddr].
|
||||||
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>;
|
fn has_element_at(&self, addr: &PoolAddr) -> Result<bool, PoolError>;
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ mod alloc_mod {
|
|||||||
/// fitting subpool is full. This might be added in the future.
|
/// fitting subpool is full. This might be added in the future.
|
||||||
///
|
///
|
||||||
/// Transactions with the [pool][StaticMemoryPool] are done using a generic
|
/// Transactions with the [pool][StaticMemoryPool] are done using a generic
|
||||||
/// [address][StoreAddr] type. Adding any data to the pool will yield a store address.
|
/// [address][PoolAddr] 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
|
/// Modification and read operations are done using a reference to a store address. Deletion
|
||||||
/// will consume the store address.
|
/// will consume the store address.
|
||||||
pub struct StaticMemoryPool {
|
pub struct StaticMemoryPool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user