pub struct DiagnosticSink { /* private fields */ }Expand description
Thread-safe sink for Diagnostic events keyed by
DiagnosticKey. Uses BTreeMap so iteration order is
deterministic (driven by DiagnosticKey’s Ord) independent of
insertion order. First writer per key wins; canonicalisation at
insertion time means payloads for the same key are identical by
construction.
Implementations§
Source§impl DiagnosticSink
impl DiagnosticSink
Sourcepub fn new() -> DiagnosticSink
pub fn new() -> DiagnosticSink
Creates an empty deterministic diagnostic sink.
Sourcepub fn push(&self, diagnostic: Diagnostic)
pub fn push(&self, diagnostic: Diagnostic)
Insert a diagnostic if no diagnostic with the same key has been inserted yet. Canonicalises the payload before insertion so later equality checks are stable.
Sourcepub fn for_each<F>(&self, f: F)where
F: FnMut(&Diagnostic),
pub fn for_each<F>(&self, f: F)where
F: FnMut(&Diagnostic),
Run a closure over the BTreeMap iterator. Held under the mutex
for the duration of the closure; keep it short.
Sourcepub fn snapshot(&self) -> Vec<Diagnostic>
pub fn snapshot(&self) -> Vec<Diagnostic>
Snapshot the diagnostics as a new Vec. Useful for tests; in
hot paths prefer for_each.
Trait Implementations§
Source§impl Clone for DiagnosticSink
impl Clone for DiagnosticSink
Source§fn clone(&self) -> DiagnosticSink
fn clone(&self) -> DiagnosticSink
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiagnosticSink
impl Debug for DiagnosticSink
Source§impl Default for DiagnosticSink
impl Default for DiagnosticSink
Source§fn default() -> DiagnosticSink
fn default() -> DiagnosticSink
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DiagnosticSink
impl RefUnwindSafe for DiagnosticSink
impl Send for DiagnosticSink
impl Sync for DiagnosticSink
impl Unpin for DiagnosticSink
impl UnsafeUnpin for DiagnosticSink
impl UnwindSafe for DiagnosticSink
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