Skip to main content

StaticMemoryManager

Struct StaticMemoryManager 

Source
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_mut return small guard types that update the per-slot borrow counter and restore it on Drop. Conflicts return explicit MemoryError values.

Implementations§

Source§

impl<P: Payload, const DEPTH: usize> StaticMemoryManager<P, DEPTH>

Source

pub fn new() -> Self

Create a new manager with all slots empty.

memory_class defaults to MemoryClass::Host.

Source

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> Default for StaticMemoryManager<P, DEPTH>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<P: Payload, const DEPTH: usize> HeaderStore for StaticMemoryManager<P, DEPTH>

Source§

type HeaderGuard<'a> = StaticHeaderGuard<'a> where Self: 'a

Guard type returned by HeaderStore::peek_header. Read more
Source§

fn peek_header( &self, token: MessageToken, ) -> Result<Self::HeaderGuard<'_>, MemoryError>

Borrow the header of the message identified by token. Read more
Source§

impl<P: Payload, const DEPTH: usize> MemoryManager<P> for StaticMemoryManager<P, DEPTH>

Source§

type ReadGuard<'a> = StaticReadGuard<'a, P> where Self: 'a

Shared read guard returned by MemoryManager::read. Read more
Source§

type WriteGuard<'a> = StaticWriteGuard<'a, P> where Self: 'a

Exclusive mutable guard returned by MemoryManager::read_mut. Read more
Source§

fn store(&mut self, value: Message<P>) -> Result<MessageToken, MemoryError>

Allocate storage for value and return its token. Read more
Source§

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>

Borrow a stored message mutably. Read more
Source§

fn free(&mut self, token: MessageToken) -> Result<(), MemoryError>

Free the slot identified by token. Read more
Source§

fn available(&self) -> usize

Return the number of currently free slots. Read more
Source§

fn capacity(&self) -> usize

Return the total slot capacity of the manager.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.