pub trait EventQueue:
Send
+ Sync
+ 'static {
// Required methods
fn push(&self, event: OwnedEvent);
fn drain_batch(&self, n: usize) -> Vec<OwnedEvent>;
fn len(&self) -> usize;
fn discard_all(&self);
fn peek_recent(&self, n: usize) -> Vec<OwnedEvent>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
FIFO event buffer with capped size and oldest-eviction.
Send + Sync is required because adapters typically own a worker
thread that drains the queue while the UI thread pushes; the
trait’s contract is “thread-safe enough for a producer/consumer
pair.”
Required Methods§
Sourcefn push(&self, event: OwnedEvent)
fn push(&self, event: OwnedEvent)
Append an event to the tail. If the queue is at capacity, the oldest entry is dropped (FIFO eviction).
Sourcefn drain_batch(&self, n: usize) -> Vec<OwnedEvent>
fn drain_batch(&self, n: usize) -> Vec<OwnedEvent>
Take up to n events from the head, removing them. Used by
adapter workers to assemble batches for HTTP transmission.
Sourcefn discard_all(&self)
fn discard_all(&self)
Drop everything without sending. Called on consent revocation
and on UsageReporter::erase_remote_data. Implementations
MUST guarantee no buffered event escapes after this returns.
Sourcefn peek_recent(&self, n: usize) -> Vec<OwnedEvent>
fn peek_recent(&self, n: usize) -> Vec<OwnedEvent>
Snapshot the head of the queue (clone). Used by the
PrivacySettings “Inspect data sent” view. Best-effort — the
returned events may have been drained by the time the caller
reads them.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".