Skip to main content

EventQueue

Trait EventQueue 

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

Source

fn push(&self, event: OwnedEvent)

Append an event to the tail. If the queue is at capacity, the oldest entry is dropped (FIFO eviction).

Source

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.

Source

fn len(&self) -> usize

Number of events currently buffered. Includes events queued for retry.

Source

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.

Source

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§

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§