HandlerBody

Trait HandlerBody 

Source
pub trait HandlerBody: Sized {
    // Required method
    fn handler_body<'life0, 'async_trait>(
        req: Request<&'life0 mut dyn AsyncReadBody>,
    ) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn handler_method() -> Method { ... }
}
Expand description

This trait is implemented by anything that represents the incoming request type. Only one argument implementing this can be asked for in a given handler. The type that implements this is used to determine the input type expected by the handler for the sake of generating API information.

Required Methods§

Source

fn handler_body<'life0, 'async_trait>( req: Request<&'life0 mut dyn AsyncReadBody>, ) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Given a request containing arbitrary bytes, this function needs to return an instance of the type that this trait is implemented on (typically by deserializing it from the bytes provided), or else it should return an error describing what went wrong.

Provided Methods§

Source

fn handler_method() -> Method

Which HTTP method is required for this Body to be valid. By default, if a body is present in the handler we’ll expect the method to be POST. Implement this function to override that.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§