1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Runtime-agnostic buffer traits and configuration for async producer-consumer dispatch
//!
//! This module defines the buffer abstraction without runtime-specific implementations.
//! Actual buffer implementations are provided by adapter crates:
//! - `aimdb-tokio-adapter` - Tokio-based buffers (std environments)
//! - `aimdb-embassy-adapter` - Embassy-based buffers (embedded no_std)
//!
//! # Buffer Types
//!
//! Three buffering strategies are supported:
//! - **SPMC Ring**: Bounded backlog with per-consumer lag tolerance
//! - **SingleLatest**: Only newest value kept (no backlog)
//! - **Mailbox**: Single-slot with overwrite semantics
//!
//! # Design Philosophy
//!
//! Each record type can choose the appropriate buffer based on its data flow:
//! - High-frequency telemetry → SPMC ring
//! - Configuration state → SingleLatest
//! - Commands/triggers → Mailbox
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────┐
//! │ aimdb-core (trait layer) │
//! │ BufferBackend<T> + BufferReader<T> + BufferCfg │
//! └────────────────┬────────────────────────────────┘
//! │
//! ┌───────────┴───────────┐
//! │ │
//! ▼ ▼
//! ┌─────────────┐ ┌──────────────────┐
//! │ tokio impl │ │ embassy impl │
//! │ (std) │ │ (no_std) │
//! └─────────────┘ └──────────────────┘
//! ```
//!
//! # Example
//!
//! ```rust,ignore
//! use aimdb_core::buffer::BufferCfg;
//!
//! // High-frequency sensor data
//! reg.buffer(BufferCfg::SpmcRing { capacity: 2048 })
//! .source(|em, data| async { ... })
//! .tap(|em, data| async { ... });
//!
//! // Configuration updates
//! reg.buffer(BufferCfg::SingleLatest)
//! .source(|em, cfg| async { ... })
//! .tap(|em, cfg| async { ... });
//! ```
extern crate alloc;
// Module structure
// Public API exports
pub use BufferCfg;
pub use ;
// JSON streaming support (std only)
pub use JsonBufferReader;
// Buffer metrics (std only, feature-gated)
pub use ;
// Re-export buffer-specific errors from core error module
// These are type aliases for convenience
pub use crateDbError as BufferError;
/// Result type for buffer operations
pub type BufferResult<T> = ;