Skip to main content

DebugEventStore

Struct DebugEventStore 

Source
pub struct DebugEventStore { /* private fields */ }
Expand description

Event store for debug sessions with subscription support.

Uses interior mutability (Mutex) so it can be shared via Arc between the executor (which owns the DebugAwareEventStore) and the protocol handler.

Implementations§

Source§

impl DebugEventStore

Source

pub fn new(session_id: String) -> Self

Creates a new DebugEventStore with the given session ID and default capacity.

Source

pub fn with_capacity(session_id: String, max_events: usize) -> Self

Creates a new DebugEventStore with the given session ID and max event capacity.

Source

pub fn session_id(&self) -> &str

Returns the session ID.

Source

pub fn max_events(&self) -> usize

Returns the max event capacity.

Source

pub fn append(&self, event: NetEvent)

Appends an event, evicting oldest if at capacity, and broadcasts to subscribers.

Source

pub fn events(&self) -> Vec<NetEvent>

Returns a snapshot of all retained events.

Source

pub fn event_count(&self) -> usize

Total number of events ever appended (including evicted).

Source

pub fn size(&self) -> usize

Number of retained events.

Source

pub fn is_empty(&self) -> bool

Returns true if no events are retained.

Source

pub fn evicted_count(&self) -> usize

Number of events evicted from the store.

Source

pub fn subscribe(&self) -> (Receiver<NetEvent>, Subscription)

Subscribe to receive events as they occur.

Returns a crossbeam_channel::Receiver for receiving events and a Subscription handle for cancellation.

Source

pub fn subscriber_count(&self) -> usize

Number of active subscribers.

Source

pub fn events_from(&self, from_index: usize) -> Vec<NetEvent>

Returns events starting from a specific global index.

Source

pub fn events_since(&self, from: u64) -> Vec<NetEvent>

Returns all events since the specified timestamp.

Source

pub fn events_between(&self, from: u64, to: u64) -> Vec<NetEvent>

Returns events within a time range [from, to).

Source

pub fn close(&self)

Closes the store, removing all subscribers.

Trait Implementations§

Source§

impl Debug for DebugEventStore

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.