pub trait ApiExtractor<'a>: Sized {
type ParamType;
type ParamRawType;
const TYPES: &'static [ApiExtractorType];
const PARAM_IS_REQUIRED: bool = false;
// Required method
fn from_request(
request: &'a Request,
body: &mut RequestBody,
param_opts: ExtractParamOptions<Self::ParamType>,
) -> impl Future<Output = Result<Self>> + Send;
// Provided methods
fn register(registry: &mut Registry) { ... }
fn security_schemes() -> Vec<&'static str> { ... }
fn has_security_fallback() -> bool { ... }
fn param_in() -> Option<MetaParamIn> { ... }
fn param_schema_ref() -> Option<MetaSchemaRef> { ... }
fn request_meta() -> Option<MetaRequest> { ... }
fn param_raw_type(&self) -> Option<&Self::ParamRawType> { ... }
}Expand description
Represents an OpenAPI extractor.
§Provided Implementations
- Path<T: Type>
Extract the parameters in the request path into
Path.
- Query<T: Type>
Extract the parameters in the query string into
Query.
- Header<T: Type>
Extract the parameters in the request header into
Header.
- Cookie<T: Type>
Extract the parameters in the cookie into
Cookie.
- CookiePrivate<T: Type>
Extract the parameters in the private cookie into
CookiePrivate.
- CookieSigned<T: Type>
Extract the parameters in the signed cookie into
CookieSigned.
- Binary<T>
Extract the request body as binary into
Binary.
- Json<T>
Parse the request body in JSON format into
Json.
- PlainText<T>
Extract the request body as utf8 string into
PlainText.
- Any type derived from the
ApiRequestmacro
Extract the complex request body derived from the ApiRequest macro.
- Any type derived from the
Multipartmacro
Extract the multipart object derived from the Multipart macro.
- Any type derived from the
SecuritySchememacro
Extract the authentication value derived from the SecurityScheme
macro.
- T: poem::FromRequest
Use Poem’s extractor.
Required Associated Constants§
Sourceconst TYPES: &'static [ApiExtractorType]
const TYPES: &'static [ApiExtractorType]
The type of API extractor.
Provided Associated Constants§
Sourceconst PARAM_IS_REQUIRED: bool = false
const PARAM_IS_REQUIRED: bool = false
If it is true, it means that this parameter is required.
Required Associated Types§
Sourcetype ParamRawType
type ParamRawType
The raw parameter type for validators.
Required Methods§
Sourcefn from_request(
request: &'a Request,
body: &mut RequestBody,
param_opts: ExtractParamOptions<Self::ParamType>,
) -> impl Future<Output = Result<Self>> + Send
fn from_request( request: &'a Request, body: &mut RequestBody, param_opts: ExtractParamOptions<Self::ParamType>, ) -> impl Future<Output = Result<Self>> + Send
Parse from the HTTP request.
Provided Methods§
Sourcefn security_schemes() -> Vec<&'static str>
fn security_schemes() -> Vec<&'static str>
Returns names of security scheme if this extractor is security scheme.
Sourcefn has_security_fallback() -> bool
fn has_security_fallback() -> bool
Returns true if the extractor is a security scheme with a fallback.
Sourcefn param_in() -> Option<MetaParamIn>
fn param_in() -> Option<MetaParamIn>
Returns the location of the parameter if this extractor is parameter.
Sourcefn param_schema_ref() -> Option<MetaSchemaRef>
fn param_schema_ref() -> Option<MetaSchemaRef>
Returns the schema of the parameter if this extractor is parameter.
Sourcefn request_meta() -> Option<MetaRequest>
fn request_meta() -> Option<MetaRequest>
Returns MetaRequest if this extractor is request object.
Sourcefn param_raw_type(&self) -> Option<&Self::ParamRawType>
fn param_raw_type(&self) -> Option<&Self::ParamRawType>
Returns a reference to the raw type of this parameter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<'a, T: DeserializeOwned + Type> ApiExtractor<'a> for Form<T>
impl<'a, T: DeserializeOwned + Type> ApiExtractor<'a> for Form<T>
Source§impl<'a, T: FromRequest<'a>> ApiExtractor<'a> for T
impl<'a, T: FromRequest<'a>> ApiExtractor<'a> for T
Source§impl<'a, T: ParseFromJSON> ApiExtractor<'a> for Json<T>
impl<'a, T: ParseFromJSON> ApiExtractor<'a> for Json<T>
Source§impl<'a, T: ParseFromParameter> ApiExtractor<'a> for Cookie<T>
Available on crate feature cookie only.
impl<'a, T: ParseFromParameter> ApiExtractor<'a> for Cookie<T>
cookie only.const TYPES: &'static [ApiExtractorType]
const PARAM_IS_REQUIRED: bool = T::IS_REQUIRED
type ParamType = T
type ParamRawType = <T as Type>::RawValueType
Source§impl<'a, T: ParseFromParameter> ApiExtractor<'a> for CookiePrivate<T>
Available on crate feature cookie only.
impl<'a, T: ParseFromParameter> ApiExtractor<'a> for CookiePrivate<T>
cookie only.const TYPES: &'static [ApiExtractorType]
const PARAM_IS_REQUIRED: bool = T::IS_REQUIRED
type ParamType = T
type ParamRawType = <T as Type>::RawValueType
Source§impl<'a, T: ParseFromParameter> ApiExtractor<'a> for CookieSigned<T>
Available on crate feature cookie only.
impl<'a, T: ParseFromParameter> ApiExtractor<'a> for CookieSigned<T>
cookie only.