Struct Analytics Queue
pub struct AnalyticsQueue { /* private fields */ }Expand description
In-memory opt-in queue, disabled initially. Limits: 1..1,024 events and 13..1,048,576 bytes for the complete JSON batch. Overflow rejects the newest event without changing accepted events. Disabling discards all queued data. Enabling must be an explicit consumer action after its own consent decision; RAVET supplies no user-consent UI, collection policy or product endpoint.
Only explicit flush calls the consumer’s sender, synchronously on its
worker thread. Failed sends retain the complete batch for an explicit retry;
successful sends remove it. Delivery is at-least-once under response loss,
not exactly-once. This module never retries, persists or schedules itself.
All methods/drop allocate/deallocate or may call blocking consumer code and
must stay outside audio callbacks. Exclusive ownership serializes revocation
against flush; it cannot retract data already accepted by a sender.
Implementations§
§impl AnalyticsQueue
impl AnalyticsQueue
pub fn new( maximum_events: usize, maximum_bytes: usize, ) -> Result<Self, AnalyticsError>
pub fn is_enabled(&self) -> bool
pub fn pending(&self) -> usize
pub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Explicit consumer opt-in; false also erases pending events immediately.
pub fn record( &mut self, event: AnalyticsEvent, ) -> Result<RecordOutcome, AnalyticsError>
pub fn flush<E>(
&mut self,
sender: impl FnOnce(&[u8]) -> Result<(), E>,
) -> Result<usize, E>
pub fn flush<E>( &mut self, sender: impl FnOnce(&[u8]) -> Result<(), E>, ) -> Result<usize, E>
No sender invocation when disabled or empty. Sender chooses destination, credentials, timeout and what counts as acceptance (e.g. HTTPS 2xx only). A sender error leaves all pending events unchanged; a panic also retains them during unwinding. The batch contains only validated numeric events.