pub struct AsyncValidatedJson<T>(pub T);Expand description
Async validated JSON body extractor
Parses the request body as JSON, deserializes into type T, and validates
using the AsyncValidate trait from rustapi-validate.
This extractor supports async validation rules, such as database uniqueness checks.
§Example
ⓘ
use rustapi_rs::prelude::*;
use rustapi_validate::v2::prelude::*;
#[derive(Deserialize, Validate, AsyncValidate)]
struct CreateUser {
#[validate(email)]
email: String,
#[validate(async_unique(table = "users", column = "email"))]
username: String,
}
async fn register(AsyncValidatedJson(body): AsyncValidatedJson<CreateUser>) -> impl IntoResponse {
// body is validated asynchronously (e.g. checked existing email in DB)
}Tuple Fields§
§0: TImplementations§
Source§impl<T> AsyncValidatedJson<T>
impl<T> AsyncValidatedJson<T>
Sourcepub fn new(value: T) -> AsyncValidatedJson<T>
pub fn new(value: T) -> AsyncValidatedJson<T>
Create a new AsyncValidatedJson wrapper
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get the inner value
Trait Implementations§
Source§impl<T> Clone for AsyncValidatedJson<T>where
T: Clone,
impl<T> Clone for AsyncValidatedJson<T>where
T: Clone,
Source§fn clone(&self) -> AsyncValidatedJson<T>
fn clone(&self) -> AsyncValidatedJson<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for AsyncValidatedJson<T>where
T: Debug,
impl<T> Debug for AsyncValidatedJson<T>where
T: Debug,
Source§impl<T> Default for AsyncValidatedJson<T>where
T: Default,
impl<T> Default for AsyncValidatedJson<T>where
T: Default,
Source§fn default() -> AsyncValidatedJson<T>
fn default() -> AsyncValidatedJson<T>
Returns the “default value” for a type. Read more
Source§impl<T> Deref for AsyncValidatedJson<T>
impl<T> Deref for AsyncValidatedJson<T>
Source§impl<T> DerefMut for AsyncValidatedJson<T>
impl<T> DerefMut for AsyncValidatedJson<T>
Source§impl<T> From<T> for AsyncValidatedJson<T>
impl<T> From<T> for AsyncValidatedJson<T>
Source§fn from(value: T) -> AsyncValidatedJson<T>
fn from(value: T) -> AsyncValidatedJson<T>
Converts to this type from the input type.
Source§impl<T> FromRequest for AsyncValidatedJson<T>
impl<T> FromRequest for AsyncValidatedJson<T>
Source§async fn from_request(
req: &mut Request,
) -> Result<AsyncValidatedJson<T>, ApiError>
async fn from_request( req: &mut Request, ) -> Result<AsyncValidatedJson<T>, ApiError>
Extract from the full request
Source§impl<T> IntoResponse for AsyncValidatedJson<T>where
T: Serialize,
impl<T> IntoResponse for AsyncValidatedJson<T>where
T: Serialize,
Source§fn into_response(self) -> Response<Body>
fn into_response(self) -> Response<Body>
Convert self into a Response
impl<T> Copy for AsyncValidatedJson<T>where
T: Copy,
Auto Trait Implementations§
impl<T> Freeze for AsyncValidatedJson<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsyncValidatedJson<T>where
T: RefUnwindSafe,
impl<T> Send for AsyncValidatedJson<T>where
T: Send,
impl<T> Sync for AsyncValidatedJson<T>where
T: Sync,
impl<T> Unpin for AsyncValidatedJson<T>where
T: Unpin,
impl<T> UnwindSafe for AsyncValidatedJson<T>where
T: 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, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of
Access::load.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