pub struct StaticMemoryManager<P: Payload, const DEPTH: usize> { /* private fields */ }Expand description
A fixed-capacity memory manager backed by [Option<Message<P>>; DEPTH].
Behavior depends on the checked-memory-manager-refs feature:
- Feature disabled (default): guard associated types are plain references:
&MessageHeader,&Message<P>,&mut Message<P>— zero-cost, suitable for MCU/no-alloc builds. - Feature enabled: per-slot borrow counters are kept (u16).
peek_header,read,read_mutreturn small guard types that update the per-slot borrow counter and restore it onDrop. Conflicts return explicitMemoryErrorvalues.
Implementations§
Source§impl<P: Payload, const DEPTH: usize> StaticMemoryManager<P, DEPTH>
impl<P: Payload, const DEPTH: usize> StaticMemoryManager<P, DEPTH>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new manager with all slots empty.
memory_class defaults to MemoryClass::Host.
Sourcepub fn with_memory_class(mem_class: MemoryClass) -> Self
pub fn with_memory_class(mem_class: MemoryClass) -> Self
Create a new manager with a specific memory class.
Trait Implementations§
Source§impl<P: Payload, const DEPTH: usize> HeaderStore for StaticMemoryManager<P, DEPTH>
impl<P: Payload, const DEPTH: usize> HeaderStore for StaticMemoryManager<P, DEPTH>
Source§type HeaderGuard<'a> = StaticHeaderGuard<'a>
where
Self: 'a
type HeaderGuard<'a> = StaticHeaderGuard<'a> where Self: 'a
Guard type returned by
HeaderStore::peek_header. Read moreSource§fn peek_header(
&self,
token: MessageToken,
) -> Result<Self::HeaderGuard<'_>, MemoryError>
fn peek_header( &self, token: MessageToken, ) -> Result<Self::HeaderGuard<'_>, MemoryError>
Borrow the header of the message identified by
token. Read moreSource§impl<P: Payload, const DEPTH: usize> MemoryManager<P> for StaticMemoryManager<P, DEPTH>
impl<P: Payload, const DEPTH: usize> MemoryManager<P> for StaticMemoryManager<P, DEPTH>
Source§type ReadGuard<'a> = StaticReadGuard<'a, P>
where
Self: 'a
type ReadGuard<'a> = StaticReadGuard<'a, P> where Self: 'a
Shared read guard returned by
MemoryManager::read. Read moreSource§type WriteGuard<'a> = StaticWriteGuard<'a, P>
where
Self: 'a
type WriteGuard<'a> = StaticWriteGuard<'a, P> where Self: 'a
Exclusive mutable guard returned by
MemoryManager::read_mut. Read moreSource§fn store(&mut self, value: Message<P>) -> Result<MessageToken, MemoryError>
fn store(&mut self, value: Message<P>) -> Result<MessageToken, MemoryError>
Allocate storage for
value and return its token. Read moreSource§fn read(&self, token: MessageToken) -> Result<Self::ReadGuard<'_>, MemoryError>
fn read(&self, token: MessageToken) -> Result<Self::ReadGuard<'_>, MemoryError>
Borrow a stored message immutably. Read more
Source§fn read_mut(
&mut self,
token: MessageToken,
) -> Result<Self::WriteGuard<'_>, MemoryError>
fn read_mut( &mut self, token: MessageToken, ) -> Result<Self::WriteGuard<'_>, MemoryError>
Borrow a stored message mutably. Read more
Source§fn free(&mut self, token: MessageToken) -> Result<(), MemoryError>
fn free(&mut self, token: MessageToken) -> Result<(), MemoryError>
Free the slot identified by
token. Read moreSource§fn memory_class(&self) -> MemoryClass
fn memory_class(&self) -> MemoryClass
Return the memory class represented by this manager. Read more
Auto Trait Implementations§
impl<P, const DEPTH: usize> !Freeze for StaticMemoryManager<P, DEPTH>
impl<P, const DEPTH: usize> !RefUnwindSafe for StaticMemoryManager<P, DEPTH>
impl<P, const DEPTH: usize> Send for StaticMemoryManager<P, DEPTH>where
P: Send,
impl<P, const DEPTH: usize> !Sync for StaticMemoryManager<P, DEPTH>
impl<P, const DEPTH: usize> Unpin for StaticMemoryManager<P, DEPTH>where
P: Unpin,
impl<P, const DEPTH: usize> UnsafeUnpin for StaticMemoryManager<P, DEPTH>where
P: UnsafeUnpin,
impl<P, const DEPTH: usize> UnwindSafe for StaticMemoryManager<P, DEPTH>where
P: 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