Skip to main content

Report

Struct Report 

Source
pub struct Report { /* private fields */ }
Expand description

The issues found so far in one validation. Validation adds to it as it goes through a value.

It allocates when it records its first issue, not before, so a valid value never pays for it.

A report started with Report::failing_fast keeps only its first issue. Once it has that issue, it is finished and records nothing more.

Implementations§

Source§

impl Report

Source

pub const fn new() -> Self

An empty report that keeps every issue found.

Source

pub const fn failing_fast() -> Self

An empty report that keeps only the first issue found.

Source

pub const fn new_alike(&self) -> Self

An empty report that gathers as this one does: every issue, or only the first when this report is failing fast.

Use it to keep the issues found in one part of a value apart, until append moves them into this report.

Source

pub fn is_finished(&self) -> bool

Whether validation should stop, because the report is failing fast and already has its issue. A report that keeps every issue is never finished.

Source

pub fn push(&mut self, at: &Location<'_>, problem: Problem)

Records problem at the location at, unless the report is finished.

Source

pub fn push_with_message( &mut self, at: &Location<'_>, problem: Problem, message: impl Into<Cow<'static, str>>, )

Records problem at the location at, with message in place of the problem’s own message, unless the report is finished.

{name} in the message is replaced by the problem’s parameter name. Write {{ and }} for literal braces.

Source

pub fn append(&mut self, other: &mut Report)

Moves the issues in other to the end of this report, keeping their order, and leaves other empty.

A finished report takes none of them, and a report that is failing fast takes only the first. An empty report takes them without copying them.

Source

pub fn len(&self) -> usize

How many issues were found so far.

Source

pub fn is_empty(&self) -> bool

Whether no issue was found so far.

Source

pub fn into_result(self) -> Result<(), Issues>

Turns the report into a result: Ok(()) when no issue was found.

§Errors

Returns the Issues found, in the order they were found, when there is at least one.

Trait Implementations§

Source§

impl Debug for Report

Source§

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

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

impl Default for Report

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Report

§

impl Freeze for Report

§

impl Move for Report

§

impl RefUnwindSafe for Report

§

impl Send for Report

§

impl Sync for Report

§

impl Unpin for Report

§

impl UnsafeUnpin for Report

§

impl UnwindSafe for Report

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