Skip to main content

VldJson

Struct VldJson 

Source
pub struct VldJson<T>(pub T);
Available on crate feature poem-openapi only.
Expand description

A JSON request body validated with vld: 422 with every issue on failure. See the module docs.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<'a, T: Type + VldParse> ApiExtractor<'a> for VldJson<T>

Source§

const TYPES: &'static [ApiExtractorType]

The type of API extractor.
Source§

type ParamType = ()

The parameter type.
Source§

type ParamRawType = ()

The raw parameter type for validators.
Source§

fn register(registry: &mut Registry)

Register related types to registry.
Source§

fn request_meta() -> Option<MetaRequest>

Returns MetaRequest if this extractor is request object.
Source§

async fn from_request( request: &'a Request, body: &mut RequestBody, _param_opts: ExtractParamOptions<Self::ParamType>, ) -> Result<Self>

Parse from the HTTP request.
Source§

const PARAM_IS_REQUIRED: bool = false

If it is true, it means that this parameter is required.
Source§

fn security_schemes() -> Vec<&'static str>

Returns names of security scheme if this extractor is security scheme.
Source§

fn has_security_fallback() -> bool

Returns true if the extractor is a security scheme with a fallback.
Source§

fn param_in() -> Option<MetaParamIn>

Returns the location of the parameter if this extractor is parameter.
Source§

fn param_schema_ref() -> Option<MetaSchemaRef>

Returns the schema of the parameter if this extractor is parameter.
Source§

fn param_raw_type(&self) -> Option<&Self::ParamRawType>

Returns a reference to the raw type of this parameter.
Source§

impl<T: Type + Serialize> ApiResponse for VldJson<T>

Source§

fn meta() -> MetaResponses

Gets metadata of this response.
Source§

fn register(registry: &mut Registry)

Register the schema contained in this response object to the registry.
Source§

const BAD_REQUEST_HANDLER: bool = false

If true, it means that the response object has a custom bad request handler.
Source§

fn from_parse_request_error(err: Error) -> Self

Convert poem::Error to this response object.
Source§

impl<T: Clone> Clone for VldJson<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for VldJson<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for VldJson<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Serialize + Send> IntoResponse for VldJson<T>

Source§

fn into_response(self) -> Response

Consume itself and return Response.
Source§

fn with_header<K, V>(self, key: K, value: V) -> WithHeader<Self>
where K: TryInto<HeaderName>, V: TryInto<HeaderValue>, Self: Sized,

Wrap an impl IntoResponse to add a header. Read more
Source§

fn with_content_type<V>(self, content_type: V) -> WithContentType<Self>
where V: TryInto<HeaderValue>, Self: Sized,

Wrap an impl IntoResponse to with a new content type. Read more
Source§

fn with_status(self, status: StatusCode) -> WithStatus<Self>
where Self: Sized,

Wrap an impl IntoResponse to set a status code. Read more
Source§

fn with_body(self, body: impl Into<Body>) -> WithBody<Self>
where Self: Sized,

Wrap an impl IntoResponse to set a body. Read more
Source§

impl<T: Type + VldParse> ParsePayload for VldJson<T>

Source§

const IS_REQUIRED: bool = true

If it is true, it means that this payload is required.
Source§

async fn from_request(request: &Request, body: &mut RequestBody) -> Result<Self>

Parse the payload object from the HTTP request.
Source§

impl<T: PartialEq> PartialEq for VldJson<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: Type> Payload for VldJson<T>

Source§

const CONTENT_TYPE: &'static str = "application/json; charset=utf-8"

The content type of this payload.
Source§

fn check_content_type(content_type: &str) -> bool

Check the content type of incoming request
Source§

fn schema_ref() -> MetaSchemaRef

Gets schema reference of this payload.
Source§

fn register(registry: &mut Registry)

Register the schema contained in this payload to the registry.
Source§

impl<T: PartialEq> StructuralPartialEq for VldJson<T>

Auto Trait Implementations§

§

impl<T> Forget for VldJson<T>

§

impl<T> Freeze for VldJson<T>
where T: Freeze,

§

impl<T> Move for VldJson<T>

§

impl<T> RefUnwindSafe for VldJson<T>
where T: RefUnwindSafe,

§

impl<T> Send for VldJson<T>
where T: Send,

§

impl<T> Sync for VldJson<T>
where T: Sync,

§

impl<T> Unpin for VldJson<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for VldJson<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for VldJson<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoResult<T> for T
where T: IntoResponse,

Source§

fn into_result(self) -> Result<T, Error>

Consumes this value returns a poem::Result<T>.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ResponseContent for T
where T: Payload,

Source§

fn media_types() -> Vec<MetaMediaType>

Returns the media types in this content.
Source§

fn register(registry: &mut Registry)

Register the schema contained in this content to the registry.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more