pub struct TraceBuffer { /* private fields */ }Expand description
Ring buffer for trace events with Andon Cord policy.
Per Dunlap (2002): “A trace with missing input events is worse than no trace at all.”
Implementations§
Source§impl TraceBuffer
impl TraceBuffer
Sourcepub fn new(capacity: usize, policy: BufferPolicy) -> Self
pub fn new(capacity: usize, policy: BufferPolicy) -> Self
Create a new trace buffer with specified capacity and policy.
Sourcepub fn soft_andon(capacity: usize) -> Self
pub fn soft_andon(capacity: usize) -> Self
Create a Soft Andon buffer (visual indicator on overflow).
Sourcepub fn production(capacity: usize) -> Self
pub fn production(capacity: usize) -> Self
Create a production buffer (drop oldest on overflow).
Sourcepub fn push(&mut self, record: FrameRecord) -> Result<(), TraceError>
pub fn push(&mut self, record: FrameRecord) -> Result<(), TraceError>
Push a frame record to the buffer.
In AndonCord mode, this will return Err(BufferFull) if the buffer is full.
In DropOldest mode, this will drop the oldest frame to make room.
In SoftAndon mode, this will drop oldest but update AndonState for visual feedback.
§Errors
Returns TraceError::BufferFull if the buffer is full and using AndonCord policy.
Sourcepub const fn andon_state(&self) -> AndonState
pub const fn andon_state(&self) -> AndonState
Get current Andon state for visual feedback (v1.3).
Sourcepub fn try_push(&mut self, record: FrameRecord) -> Result<(), TraceError>
pub fn try_push(&mut self, record: FrameRecord) -> Result<(), TraceError>
Try to push without blocking.
§Errors
Returns TraceError::BufferFull if the buffer is full and using AndonCord policy.
Sourcepub fn pop(&mut self) -> Option<FrameRecord>
pub fn pop(&mut self) -> Option<FrameRecord>
Pop the oldest frame record from the buffer.
Sourcepub fn drain(&mut self, count: usize) -> Vec<FrameRecord>
pub fn drain(&mut self, count: usize) -> Vec<FrameRecord>
Drain up to count frames from the buffer.
Sourcepub const fn frames_dropped(&self) -> u64
pub const fn frames_dropped(&self) -> u64
Get number of dropped frames (only relevant in DropOldest mode).
Sourcepub const fn policy(&self) -> BufferPolicy
pub const fn policy(&self) -> BufferPolicy
Get buffer policy.
Sourcepub fn iter(&self) -> impl Iterator<Item = &FrameRecord>
pub fn iter(&self) -> impl Iterator<Item = &FrameRecord>
Iterate over all frames in the buffer (oldest to newest).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TraceBuffer
impl RefUnwindSafe for TraceBuffer
impl Send for TraceBuffer
impl Sync for TraceBuffer
impl Unpin for TraceBuffer
impl UnwindSafe for TraceBuffer
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more