Trait salvo_core::extract::Extractible

source ·
pub trait Extractible<'ex> {
    // Required methods
    fn metadata() -> &'ex Metadata;
    fn extract(
        req: &'ex mut Request
    ) -> impl Future<Output = Result<Self, impl Writer + Send + Debug + 'static>> + Send
       where Self: Sized;

    // Provided method
    fn extract_with_arg(
        req: &'ex mut Request,
        _arg: &str
    ) -> impl Future<Output = Result<Self, impl Writer + Send + Debug + 'static>> + Send
       where Self: Sized { ... }
}
Expand description

If a type implements this trait, it will give a metadata, this will help request to extracts data to this type.

Required Methods§

source

fn metadata() -> &'ex Metadata

Metadata for Extractible type.

source

fn extract( req: &'ex mut Request ) -> impl Future<Output = Result<Self, impl Writer + Send + Debug + 'static>> + Send
where Self: Sized,

Extract data from request.

NOTE: Set status code to 400 if extract failed and status code is not error.

Provided Methods§

source

fn extract_with_arg( req: &'ex mut Request, _arg: &str ) -> impl Future<Output = Result<Self, impl Writer + Send + Debug + 'static>> + Send
where Self: Sized,

Extract data from request with a argument. This function used in macros internal.

Object Safety§

This trait is not object safe.

Implementors§