pub struct Diagnostics { /* private fields */ }Expand description
A growing list of findings that keeps itself in reproducible order.
Callers push in whatever order problems are noticed; Diagnostics::finish
imposes the order that makes two runs comparable.
The list is bounded. Past its ceiling, findings are counted rather than
retained, and Diagnostics::finish appends one MOLFRAME-W1901 recording
how many were suppressed. The worst severity still reflects every finding
pushed, retained or not, so a decision taken on severity is unaffected by
the ceiling.
Implementations§
Source§impl Diagnostics
impl Diagnostics
Sourcepub const DEFAULT_CEILING: usize = 10_000
pub const DEFAULT_CEILING: usize = 10_000
How many findings a list retains before it starts counting instead.
A systematically malformed column raises one finding per row, and a finding carries a message, a category, a field and a context vector — roughly ninety bytes and up to four allocations each. At a hundred million rows that is nine gigabytes of diagnostics describing a single cause, which exhausts memory reporting a problem rather than reporting it.
Ten thousand is far past the point where a reader learns anything new and far below the point where the list itself is the problem.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a list with room for capacity findings.
Worth doing when a permissive parse over a known-messy file is expected
to raise many, so the list does not grow by repeated reallocation. The
ceiling is raised to capacity where that is higher than the default,
because a caller who has reserved the room has said what they want.
Sourcepub const fn with_ceiling(self, ceiling: usize) -> Self
pub const fn with_ceiling(self, ceiling: usize) -> Self
Sets how many findings this list retains before counting instead.
Sourcepub const fn ceiling(&self) -> usize
pub const fn ceiling(&self) -> usize
How many findings this list retains before counting instead.
Sourcepub const fn suppressed(&self) -> u64
pub const fn suppressed(&self) -> u64
How many findings were counted rather than retained.
Sourcepub fn push(&mut self, finding: Diagnostic)
pub fn push(&mut self, finding: Diagnostic)
Records a finding.
Past the ceiling the finding is counted and dropped. The severity is recorded either way, so nothing that depends on the worst severity changes with the ceiling.
Sourcepub const fn worst(&self) -> Option<Severity>
pub const fn worst(&self) -> Option<Severity>
The worst severity recorded so far, if anything has been.
Sourcepub fn has_error(&self, strictness: Strictness) -> bool
pub fn has_error(&self, strictness: Strictness) -> bool
Returns true when any recorded finding is an error at this strictness.
Sourcepub fn as_slice(&self) -> &[Diagnostic]
pub fn as_slice(&self) -> &[Diagnostic]
The findings recorded so far, in the order they were pushed.
Sourcepub fn finish(self) -> Vec<Diagnostic>
pub fn finish(self) -> Vec<Diagnostic>
Consumes the list, returning the findings in reproducible order.
The sort is stable, so two findings identical on every ordering key stay in the order they were raised.
Trait Implementations§
Source§impl Clone for Diagnostics
impl Clone for Diagnostics
Source§impl Debug for Diagnostics
impl Debug for Diagnostics
Source§impl Default for Diagnostics
impl Default for Diagnostics
Source§impl Extend<Diagnostic> for Diagnostics
impl Extend<Diagnostic> for Diagnostics
Source§fn extend<T: IntoIterator<Item = Diagnostic>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Diagnostic>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Auto Trait Implementations§
impl Freeze for Diagnostics
impl RefUnwindSafe for Diagnostics
impl Send for Diagnostics
impl Sync for Diagnostics
impl Unpin for Diagnostics
impl UnsafeUnpin for Diagnostics
impl UnwindSafe for Diagnostics
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> 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