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

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

A collection of invalidities resulting from a validation

Collects invalidities that are detected while performing a validation.

Methods

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

pub fn new() -> Self[src]

Create a new valid and empty context

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

Check if the context is still valid

pub fn invalidate(self, invalidity: impl Into<V>) -> Self[src]

Record a new invalidity within this context

pub fn invalidate_if(
    self,
    is_invalid: impl Into<bool>,
    invalidity: impl Into<V>
) -> Self
[src]

Conditionally record a new invalidity within this context

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

Merge the results of another validation

Needed for collecting results from custom validation functions.

pub fn merge_result_with<F, U>(self, res: Result<U>, map: F) -> Self where
    F: Fn(U) -> V,
    U: Invalidity
[src]

Merge the mapped results of another validation

Needed for collecting results from custom validation functions.

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

Deprecated since 0.2.0:

Please use merge_result_with instead

Merge the mapped results of another validation

pub fn validate<U>(self, target: &impl Validate<Invalidity = U>) -> Self where
    U: Invalidity + Into<V>, 
[src]

Validate the target and merge the result into this context

pub fn validate_with<F, U>(
    self,
    target: &impl Validate<Invalidity = U>,
    map: F
) -> Self where
    F: Fn(U) -> V,
    U: Invalidity
[src]

Validate the target and merge the mapped result into this context

pub fn validate_and_map<F, U>(
    self,
    target: &impl Validate<Invalidity = U>,
    map: F
) -> Self where
    F: Fn(U) -> V,
    U: Invalidity
[src]

Deprecated since 0.2.0:

Please use validate_with instead

Validate the target, map the result, and merge it into this context

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

Finish the current validation of this context with a result

Trait Implementations

impl<V> Into<Result<(), Context<V>>> for Context<V> where
    V: Invalidity
[src]

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

Transform the validation context into an iterator that yields all the collected invalidities.

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: Clone> Clone for Context<V> where
    V: Invalidity
[src]

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

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

impl<T, V> IntoValidated<V> for T where
    V: ValidatedFrom<T>, 
[src]

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

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

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = !

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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