pub struct CapacityWarning {
pub kind: CapacityWarningKind,
pub scope: CapacityScope,
pub issues: Vec<u32>,
pub current: Option<u64>,
pub limit: Option<u64>,
pub overflow: Option<u64>,
pub unit: Option<String>,
pub reason: String,
pub remedy: Option<String>,
}Expand description
One shared capacity finding: what it is, what it is about, and what to do (data-model §5).
The numbers are Option because a finding is not always about a total: an issue whose
estimate could not be counted has no current/limit/overflow, and the unit it
could not be counted in is still named so the reader knows which conversion to fix.
Fields§
§kind: CapacityWarningKindWhat is wrong.
scope: CapacityScopeThe scope the finding is about.
issues: Vec<u32>The issues to look at, in issue order. Empty when the finding is about the scope itself rather than about work inside it.
current: Option<u64>The committed total the finding compares, when it compares one.
limit: Option<u64>The configured ceiling, when the finding is about a ceiling.
overflow: Option<u64>How far over the ceiling current is, when the finding is an overflow.
unit: Option<String>The unit the numbers are counted in, when the finding is about a count.
reason: StringWhat is wrong, in one sentence — the reason half of the #1643 shape.
remedy: Option<String>What the reader can do about it — the remedy half of the #1643 shape.
Implementations§
Source§impl CapacityWarning
impl CapacityWarning
Sourcepub fn new(
kind: CapacityWarningKind,
scope: CapacityScope,
reason: impl Into<String>,
) -> Self
pub fn new( kind: CapacityWarningKind, scope: CapacityScope, reason: impl Into<String>, ) -> Self
A finding about a scope, with its reason. The remedy comes from
CapacityWarningKind::default_remedy.
Sourcepub fn overflow(
scope: CapacityScope,
committed: u64,
capacity: u64,
unit: &str,
issues: Vec<u32>,
) -> Self
pub fn overflow( scope: CapacityScope, committed: u64, capacity: u64, unit: &str, issues: Vec<u32>, ) -> Self
The scope’s committed work is over its ceiling (C-006).
Carries everything the mission says an overflow warning must name: the scope, the committed value, the configured capacity, the excess, the unit, and the issues whose estimates make up the total.
Sourcepub fn from_estimate_diagnostic(
scope: CapacityScope,
issue: u32,
unit: &str,
finding: &WipDiagnostic,
) -> Self
pub fn from_estimate_diagnostic( scope: CapacityScope, issue: u32, unit: &str, finding: &WipDiagnostic, ) -> Self
A finding about one issue’s estimate, reusing the WIP mission’s kind and sentence.
The estimate value’s own diagnostic already names the issue and quotes the raw
text (src/capacity/estimate.rs), so the reason stays the registry’s sentence and
this adds the machine-readable context a surface needs: which issue, which unit.
Sourcepub fn from_scope_diagnostic(
scope: CapacityScope,
finding: &ScopeDiagnostic,
) -> Self
pub fn from_scope_diagnostic( scope: CapacityScope, finding: &ScopeDiagnostic, ) -> Self
A finding about a reference an issue wrote, reusing WP02’s kind and sentence.
Sourcepub fn unresolved_scope(scope: CapacityScope) -> Self
pub fn unresolved_scope(scope: CapacityScope) -> Self
The scope’s own reference resolves to nothing, so it selects no work.
The remedy is tailored rather than the kind’s default because the subject differs:
the default CapacityWarningKind::default_remedy for unknown_scope speaks to an
issue’s reference, while this finding is about the scope the ceiling names — and
the reference can fail to resolve because no cycle answers to it or because a
stored record’s generated identity is half written, which the identity index drops.
Sourcepub fn with_remedy(self, remedy: impl Into<String>) -> Self
pub fn with_remedy(self, remedy: impl Into<String>) -> Self
Say what to do about it, overriding the kind’s default remedy.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render through the crate’s one diagnostic renderer, remedy and all.
The headline is the reason, the notes carry the machine-readable context this
surface is not the only reader of, and the help: footer is the remedy — the
same layout crate::health::diagnostics::HealthDiagnostic::render uses.
Trait Implementations§
Source§impl Clone for CapacityWarning
impl Clone for CapacityWarning
Source§impl Debug for CapacityWarning
impl Debug for CapacityWarning
impl Eq for CapacityWarning
Source§impl PartialEq for CapacityWarning
impl PartialEq for CapacityWarning
impl StructuralPartialEq for CapacityWarning
Auto Trait Implementations§
impl Freeze for CapacityWarning
impl RefUnwindSafe for CapacityWarning
impl Send for CapacityWarning
impl Sync for CapacityWarning
impl Unpin for CapacityWarning
impl UnsafeUnpin for CapacityWarning
impl UnwindSafe for CapacityWarning
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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