pub struct Validated<S, T> { /* private fields */ }Expand description
A wrapper that proves its inner value has been validated against schema S.
S must implement vld::schema::VldParse and T must be
serde::Serialize so the value can be converted to JSON for validation.
§Example
use vld::prelude::*;
vld::schema! {
#[derive(Debug)]
pub struct NameSchema {
pub name: String => vld::string().min(1).max(50),
}
}
#[derive(serde::Serialize)]
struct Row { name: String }
let row = Row { name: "Alice".into() };
let v = vld_sqlx::Validated::<NameSchema, _>::new(row).unwrap();
assert_eq!(v.inner().name, "Alice");Implementations§
Source§impl<S, T> Validated<S, T>
impl<S, T> Validated<S, T>
Sourcepub fn new(value: T) -> Result<Self, VldSqlxError>
pub fn new(value: T) -> Result<Self, VldSqlxError>
Validate value against schema S and wrap it on success.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume and return the inner value.
Trait Implementations§
Auto Trait Implementations§
impl<S, T> Freeze for Validated<S, T>where
T: Freeze,
impl<S, T> RefUnwindSafe for Validated<S, T>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, T> Send for Validated<S, T>
impl<S, T> Sync for Validated<S, T>
impl<S, T> Unpin for Validated<S, T>
impl<S, T> UnsafeUnpin for Validated<S, T>where
T: UnsafeUnpin,
impl<S, T> UnwindSafe for Validated<S, T>where
T: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more