[][src]Struct semval::context::Context

pub struct Context<V> where
    V: Validation
{ /* fields omitted */ }

A collection of violations resulting from a validation

Collects violations that are detected while performing a validation.

Methods

impl<V> Context<V> where
    V: Validation
[src]

pub fn violations(&self) -> impl Iterator<Item = &V>[src]

The violations collected so far

pub fn has_violations(&self) -> bool[src]

Check if the context already has any violations

pub fn count_violations(&self) -> usize[src]

Count the number of violations collected so far

pub fn add_violation(&mut self, violation: impl Into<V>)[src]

Add a new violation to the context

pub fn merge_result(&mut self, res: Result<V>)[src]

Merge a validation result into the context

pub fn map_and_merge_result<F, U>(&mut self, res: Result<U>, map: F) where
    F: Fn(U) -> V,
    U: Validation
[src]

Merge an unrelated validation into the context

pub fn into_result(self) -> Result<V>[src]

Finish the current validation with a result

Returns Err with the context's violations or Ok if the context does not have any violations.

Trait Implementations

impl<V: Clone> Clone for Context<V> where
    V: Validation
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<V> Default for Context<V> where
    V: Validation
[src]

impl<V> IntoIterator for Context<V> where
    V: Validation
[src]

type Item = V

The type of the elements being iterated over.

type IntoIter = IntoIter<[V; 8]>

Which kind of iterator are we turning this into?

impl<V> Display for Context<V> where
    V: Validation + Display
[src]

impl<V: Debug> Debug for Context<V> where
    V: Validation
[src]

impl<V> Error for Context<V> where
    V: Validation + Display
[src]

fn description(&self) -> &str1.0.0[src]

This method is soft-deprecated. Read more

fn cause(&self) -> Option<&dyn Error>1.0.0[src]

Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

The lower-level cause of this error, if any. Read more

fn source(&self) -> Option<&(dyn Error + 'static)>1.30.0[src]

The lower-level source of this error, if any. Read more

Auto Trait Implementations

impl<V> Sync for Context<V> where
    V: Sync

impl<V> Send for Context<V> where
    V: Send

impl<V> Unpin for Context<V> where
    V: Unpin

impl<V> RefUnwindSafe for Context<V> where
    V: RefUnwindSafe

impl<V> UnwindSafe for Context<V> where
    V: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<V> Validation for V where
    V: Any + Debug
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]