pub trait ApiExtractor<'a>: Sized {
    type ParamType;
    type ParamRawType;

    const TYPE: ApiExtractorType;
    const PARAM_IS_REQUIRED: bool = false;

    // Required method
    fn from_request<'life0, 'async_trait>(
        request: &'a Request,
        body: &'life0 mut RequestBody,
        param_opts: ExtractParamOptions<Self::ParamType>
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'a: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn register(registry: &mut Registry) { ... }
    fn security_scheme() -> Option<&'static str> { ... }
    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 a 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 ApiRequest macro

    Extract the complex request body derived from the ApiRequest macro.

  • Any type derived from the Multipart macro

    Extract the multipart object derived from the Multipart macro.

  • Any type derived from the SecurityScheme macro

    Extract the authentication value derived from the SecurityScheme macro.

  • T: poem::FromRequest

    Use Poem’s extractor.

Required Associated Types§

source

type ParamType

The parameter type.

source

type ParamRawType

The raw parameter type for validators.

Required Associated Constants§

source

const TYPE: ApiExtractorType

The type of API extractor.

Provided Associated Constants§

source

const PARAM_IS_REQUIRED: bool = false

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

Required Methods§

source

fn from_request<'life0, 'async_trait>( request: &'a Request, body: &'life0 mut RequestBody, param_opts: ExtractParamOptions<Self::ParamType> ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Parse from the HTTP request.

Provided Methods§

source

fn register(registry: &mut Registry)

Register related types to registry.

source

fn security_scheme() -> Option<&'static str>

Returns name of security scheme if this extractor is security scheme.

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 request_meta() -> Option<MetaRequest>

Returns MetaRequest if this extractor is request object.

source

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

Returns a reference to the raw type of this parameter.

Implementors§

source§

impl<'a> ApiExtractor<'a> for Base64<Vec<u8>>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for Base64<Bytes>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for Binary<Vec<u8>>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for Binary<Bytes>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for Binary<Body>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for Html<String>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a> ApiExtractor<'a> for PlainText<String>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a, T: FromRequest<'a>> ApiExtractor<'a> for T

source§

const TYPE: ApiExtractorType = ApiExtractorType::PoemExtractor

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a, T: DeserializeOwned + Type> ApiExtractor<'a> for Form<T>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a, T: ParseFromJSON> ApiExtractor<'a> for Json<T>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a, T: ParseFromParameter> ApiExtractor<'a> for Cookie<T>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

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>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

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>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

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 Header<T>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

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 Path<T>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

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 Query<T>

source§

const TYPE: ApiExtractorType = ApiExtractorType::Parameter

source§

const PARAM_IS_REQUIRED: bool = T::IS_REQUIRED

§

type ParamType = T

§

type ParamRawType = <T as Type>::RawValueType

source§

impl<'a, T: ParseFromXML> ApiExtractor<'a> for Xml<T>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()

source§

impl<'a, T: ParseFromYAML> ApiExtractor<'a> for Yaml<T>

source§

const TYPE: ApiExtractorType = crate::ApiExtractorType::RequestObject

§

type ParamType = ()

§

type ParamRawType = ()