Skip to main content

CapacityWarning

Struct CapacityWarning 

Source
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: CapacityWarningKind

What is wrong.

§scope: CapacityScope

The 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: String

What 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

Source

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.

Source

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.

Source

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.

Source

pub fn from_scope_diagnostic( scope: CapacityScope, finding: &ScopeDiagnostic, ) -> Self

A finding about a reference an issue wrote, reusing WP02’s kind and sentence.

Source

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.

Source

pub fn for_issue(self, issue: u32) -> Self

Name one more issue the finding is about.

Source

pub fn in_unit(self, unit: &str) -> Self

Name the unit the finding is counted in.

Source

pub fn with_remedy(self, remedy: impl Into<String>) -> Self

Say what to do about it, overriding the kind’s default remedy.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CapacityWarning

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CapacityWarning

Source§

impl PartialEq for CapacityWarning

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CapacityWarning

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.