pub struct CannedMessageStore<const MAX_ENTRIES: usize = 256> { /* private fields */ }Expand description
Bounded storage for canned message events.
Uses LWW (Last-Writer-Wins) semantics per (source_node, message_type) pair. Only stores the latest event of each type from each peer.
Memory usage: approximately MAX_ENTRIES * 24 bytes.
Default capacity of 256 entries ≈ 6KB.
Implementations§
Source§impl<const MAX_ENTRIES: usize> CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> CannedMessageStore<MAX_ENTRIES>
Sourcepub fn insert(&mut self, event: CannedMessageEvent) -> bool
pub fn insert(&mut self, event: CannedMessageEvent) -> bool
Insert or update an event.
Only updates if the new event is newer than the existing one.
Returns true if the event was inserted/updated.
Sourcepub fn get(
&self,
source: NodeId,
message: CannedMessage,
) -> Option<&CannedMessageEvent>
pub fn get( &self, source: NodeId, message: CannedMessage, ) -> Option<&CannedMessageEvent>
Get the latest event of a specific type from a specific node.
Sourcepub fn events_from(
&self,
source: NodeId,
) -> impl Iterator<Item = &CannedMessageEvent>
pub fn events_from( &self, source: NodeId, ) -> impl Iterator<Item = &CannedMessageEvent>
Get all events from a specific node.
Sourcepub fn events_of_type(
&self,
message: CannedMessage,
) -> impl Iterator<Item = &CannedMessageEvent>
pub fn events_of_type( &self, message: CannedMessage, ) -> impl Iterator<Item = &CannedMessageEvent>
Get all events of a specific type.
Sourcepub fn alerts(&self) -> impl Iterator<Item = &CannedMessageEvent>
pub fn alerts(&self) -> impl Iterator<Item = &CannedMessageEvent>
Get all emergency/alert events.
Trait Implementations§
Auto Trait Implementations§
impl<const MAX_ENTRIES: usize> Freeze for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> RefUnwindSafe for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> Send for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> Sync for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> Unpin for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> UnsafeUnpin for CannedMessageStore<MAX_ENTRIES>
impl<const MAX_ENTRIES: usize> UnwindSafe for CannedMessageStore<MAX_ENTRIES>
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