Skip to main content

CannedMessageStore

Struct CannedMessageStore 

Source
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>

Source

pub const fn new() -> Self

Create a new empty store.

Source

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.

Source

pub fn get( &self, source: NodeId, message: CannedMessage, ) -> Option<&CannedMessageEvent>

Get the latest event of a specific type from a specific node.

Source

pub fn events_from( &self, source: NodeId, ) -> impl Iterator<Item = &CannedMessageEvent>

Get all events from a specific node.

Source

pub fn events_of_type( &self, message: CannedMessage, ) -> impl Iterator<Item = &CannedMessageEvent>

Get all events of a specific type.

Source

pub fn alerts(&self) -> impl Iterator<Item = &CannedMessageEvent>

Get all emergency/alert events.

Source

pub fn len(&self) -> usize

Number of stored events.

Source

pub fn is_empty(&self) -> bool

Check if store is empty.

Source

pub fn clear(&mut self)

Clear all events.

Trait Implementations§

Source§

impl<const MAX_ENTRIES: usize> Default for CannedMessageStore<MAX_ENTRIES>

Source§

fn default() -> Self

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

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> 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.