pub struct ClientRingBuffer { /* private fields */ }Expand description
Per-client debug ring buffer.
A fixed-capacity (8 KB default) ring buffer that captures client-specific events for debugging. When the buffer is full, oldest entries are discarded.
§Thread Safety
All operations are thread-safe. Multiple readers can access the buffer simultaneously; writers are exclusive.
Implementations§
Source§impl ClientRingBuffer
impl ClientRingBuffer
Sourcepub fn with_capacity(capacity_bytes: usize) -> Self
pub fn with_capacity(capacity_bytes: usize) -> Self
Creates a new ring buffer with the specified capacity in bytes.
Sourcepub fn log_event(&self, event_type: ClientEventType, details: impl Into<String>)
pub fn log_event(&self, event_type: ClientEventType, details: impl Into<String>)
Logs an event to the buffer.
If the buffer would exceed capacity, oldest entries are discarded.
Sourcepub fn log_command(&self, command: &str)
pub fn log_command(&self, command: &str)
Logs a command execution event.
Sourcepub fn log_mode_change(&self, from: &str, to: &str)
pub fn log_mode_change(&self, from: &str, to: &str)
Logs a mode change event.
Sourcepub fn log_state_change(&self, description: &str)
pub fn log_state_change(&self, description: &str)
Logs a state change event.
Sourcepub fn tail(&self, n: usize) -> Vec<ClientLogEntry>
pub fn tail(&self, n: usize) -> Vec<ClientLogEntry>
Returns the N most recent entries (newest first).
Sourcepub fn entries(&self) -> Vec<ClientLogEntry>
pub fn entries(&self) -> Vec<ClientLogEntry>
Returns all entries in order (oldest to newest).
Sourcepub fn dump(&self) -> String
pub fn dump(&self) -> String
Formats all entries as a string for crash dumps.
Blocks until the lock is acquired.
Sourcepub fn try_dump(&self) -> Option<String>
pub fn try_dump(&self) -> Option<String>
Attempts to format all entries without blocking.
Returns None if the lock cannot be acquired immediately.
Use this in panic handlers to avoid deadlocks.
Sourcepub fn stats(&self) -> ClientBufferStats
pub fn stats(&self) -> ClientBufferStats
Returns buffer statistics.
Sourcepub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Returns the current byte usage.
Trait Implementations§
Source§impl Clone for ClientRingBuffer
impl Clone for ClientRingBuffer
Source§impl Debug for ClientRingBuffer
impl Debug for ClientRingBuffer
Auto Trait Implementations§
impl !Freeze for ClientRingBuffer
impl !RefUnwindSafe for ClientRingBuffer
impl Send for ClientRingBuffer
impl Sync for ClientRingBuffer
impl Unpin for ClientRingBuffer
impl UnsafeUnpin for ClientRingBuffer
impl UnwindSafe for ClientRingBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request