BufferCfg

Enum BufferCfg 

Source
pub enum BufferCfg {
    SpmcRing {
        capacity: usize,
    },
    SingleLatest,
    Mailbox,
}
Expand description

Buffer configuration for a record type

Selects buffering strategy: SPMC Ring (backlog), SingleLatest (state sync), or Mailbox (commands).

§Quick Selection Guide

  • High-frequency data (>10 Hz): SpmcRing with tuned capacity
  • State/config updates: SingleLatest (only latest matters)
  • Commands/one-shot events: Mailbox

§Examples

use aimdb_core::buffer::BufferCfg;

let telemetry = BufferCfg::SpmcRing { capacity: 2048 };  // High-freq data
let config = BufferCfg::SingleLatest;                     // State sync
let commands = BufferCfg::Mailbox;                        // Commands

Variants§

§

SpmcRing

SPMC (Single Producer, Multiple Consumer) ring buffer

Best for high-frequency data streams with bounded memory. Fast producers can outrun slow consumers (lag detection). Oldest messages dropped on overflow.

Sizing: capacity = data_rate_hz × lag_seconds (use power-of-2)

Fields

§capacity: usize

Maximum number of items in the buffer

§

SingleLatest

Single latest value buffer (no backlog)

Only most recent value is kept. Consumers always get latest state. Intermediate updates are collapsed. Use when history doesn’t matter.

§

Mailbox

Single-slot mailbox with overwrite

New value overwrites old if not consumed. At-least-once delivery. Use for commands where latest command wins.

Implementations§

Source§

impl BufferCfg

Source

pub fn validate(&self) -> Result<(), &'static str>

Validates the buffer configuration

Returns Err if SPMC Ring capacity is 0.

Source

pub fn name(&self) -> &'static str

Returns a human-readable name for this buffer type

Source

pub fn estimated_memory_bytes( &self, item_size: usize, consumer_count: usize, ) -> usize

Returns estimated memory overhead for this buffer type

Approximation; varies by implementation and platform.

Trait Implementations§

Source§

impl Clone for BufferCfg

Source§

fn clone(&self) -> BufferCfg

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BufferCfg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BufferCfg

Source§

fn default() -> Self

Returns the default buffer configuration: SpmcRing { capacity: 1024 }

Source§

impl<'de> Deserialize<'de> for BufferCfg

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BufferCfg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BufferCfg

Source§

fn eq(&self, other: &BufferCfg) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BufferCfg

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for BufferCfg

Source§

impl StructuralPartialEq for BufferCfg

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,