pub struct RecordingSink { /* private fields */ }Expand description
A simple recording sink that accumulates events in insertion order.
Backed by a Mutex<Vec<TraceEvent>> so the sink is Send + Sync and
can be shared across threads via Arc<RecordingSink> and installed
through with_global_sink / set_global_sink. The single-thread
Rc<RecordingSink> path through with_sink continues to work and
pays only the Mutex acquisition cost when an event is recorded
(still zero-cost when no sink is installed).
Implementations§
Source§impl RecordingSink
impl RecordingSink
Sourcepub fn events(&self) -> Vec<TraceEvent>
pub fn events(&self) -> Vec<TraceEvent>
Snapshot the recorded events.
Sourcepub fn to_canonical_json(&self) -> String
pub fn to_canonical_json(&self) -> String
Render all events to canonical JSON.
Trait Implementations§
Source§impl Debug for RecordingSink
impl Debug for RecordingSink
Source§impl Default for RecordingSink
impl Default for RecordingSink
Source§fn default() -> RecordingSink
fn default() -> RecordingSink
Returns the “default value” for a type. Read more
Source§impl Sink for RecordingSink
impl Sink for RecordingSink
Source§fn record(&self, event: TraceEvent)
fn record(&self, event: TraceEvent)
Receive a single event. Implementations should not perform I/O
or take locks that risk contention with engine work.
Auto Trait Implementations§
impl !Freeze for RecordingSink
impl RefUnwindSafe for RecordingSink
impl Send for RecordingSink
impl Sync for RecordingSink
impl Unpin for RecordingSink
impl UnsafeUnpin for RecordingSink
impl UnwindSafe for RecordingSink
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
Mutably borrows from an owned value. Read more