[][src]Struct vale::Valid

pub struct Valid<T> { /* fields omitted */ }

A struct that can be used in Rocket routes. If you have some type that implements Validate, you can designate in your controller that you want to have a validated instance of that type.

Example

use vale::Valid;

#[rocket::post("/user", data = "<user>")]
fn update_user(user: Valid<User>) {
    // user is now validated, this code is not reached if the validation failed
}

It is also possible to nest this type with other wrappers:

#[rocket::post("/user", data = "<user>")]
fn update_user(user: Valid<Json<User>>) {
    let user = user.into_inner().into_inner();
}

Features

Requires the rocket feature to be enabled

Implementations

impl<T: Validate> Valid<T>[src]

pub fn into_inner(self) -> T[src]

Consumes the Valid wrapper and returns the inner item.

Trait Implementations

impl<T: Validate> Deref for Valid<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Validate> DerefMut for Valid<T>[src]

impl<'a, T: 'a> FromData<'a> for Valid<T> where
    T: FromData<'a> + Validate
[src]

type Error = ValidationError<T::Error>

The associated error to be returned when the guard fails.

type Owned = T::Owned

The owned type returned from FromData::transform(). Read more

type Borrowed = T::Borrowed

The borrowed type consumed by FromData::from_data() when FromData::transform() returns a Transform::Borrowed. Read more

Auto Trait Implementations

impl<T> RefUnwindSafe for Valid<T> where
    T: RefUnwindSafe

impl<T> Send for Valid<T> where
    T: Send

impl<T> Sync for Valid<T> where
    T: Sync

impl<T> Unpin for Valid<T> where
    T: Unpin

impl<T> UnwindSafe for Valid<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T, I> AsResult<T, I> for T where
    I: Input, 

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

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

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

impl<'a, T> FromData<'a> for T where
    T: FromDataSimple
[src]

type Error = <T as FromDataSimple>::Error

The associated error to be returned when the guard fails.

type Owned = Data

The owned type returned from FromData::transform(). Read more

type Borrowed = Data

The borrowed type consumed by FromData::from_data() when FromData::transform() returns a Transform::Borrowed. Read more

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

impl<T> IntoCollection<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

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> Typeable for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T, U> Validate for U where
    T: Validate,
    U: Deref<Target = T> + DerefMut
[src]