Skip to main content

GateOutcome

Struct GateOutcome 

Source
pub struct GateOutcome {
    pub status: GateStatus,
    pub enforced: bool,
    pub observed: Option<f64>,
    pub threshold: Option<f64>,
    pub threshold_label: Option<String>,
    pub files: Vec<GateFile>,
}
Expand description

One gate’s verdict on one run.

status and enforced answer different questions, and they can disagree. status is what the rule concluded. enforced tells if a fail from this gate makes the run exit non-zero. A run that was told never to fail reports a failed gate as status: fail with enforced: false.

A gate fails the build when status is fail AND enforced is true. One member alone does not decide it. enforced is true on every armed gate, also on a gate that passed. Thus a gate rule on enforced alone fails every run that armed a gate. Read status alone to decide what to say. warn and skipped are not a pass and not a failure.

Fields§

§status: GateStatus

What the rule concluded.

§enforced: bool

True when a fail from this gate makes the run exit non-zero. False when the tool publishes the verdict for information only: no flag or config armed the gate, the run was told never to fail, or the output format exits 0 for the gate.

§observed: Option<f64>

The measured value that the gate compared, when there is one: for example a percentage, a score, a number of findings, or the number of files in files. A whole number is a JSON number, so a count of three reads as 3.0. Absent for a gate that compares no number.

§threshold: Option<f64>

The configured limit that the gate compared observed against, when there is one. Absent for a gate that compares no number.

§threshold_label: Option<String>

How the limit was spelled, for a gate whose threshold number does not carry its unit. Examples are a severity floor such as high, the rule severity that the gate counts such as error, or a tolerance as the user wrote it, such as "50%". Each gate name documents its label. Absent for a gate whose numbers have a clear meaning without a label.

§files: Vec<GateFile>

The files that the gate judged, for a gate that judges files and not a number. One item for each file, sorted by path. Absent when the list is empty.

Implementations§

Source§

impl GateOutcome

Source

pub const fn new(status: GateStatus, enforced: bool) -> Self

A gate that ran, compared no number, and was armed.

Source

pub const fn measured( status: GateStatus, enforced: bool, observed: f64, threshold: f64, ) -> Self

A gate that compared observed against threshold.

Source

pub fn counted( status: GateStatus, enforced: bool, observed: f64, threshold_label: &str, ) -> Self

A gate that counted observed items at or above a named floor.

Source

pub fn with_files( status: GateStatus, enforced: bool, files: Vec<GateFile>, ) -> Self

A gate that judged files: observed is the number of files it named.

Source

pub const fn fails_run(&self) -> bool

Whether this outcome should make the run exit non-zero.

Trait Implementations§

Source§

impl Clone for GateOutcome

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 GateOutcome

Source§

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

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

impl PartialEq for GateOutcome

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 Serialize for GateOutcome

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GateOutcome

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<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> 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.