argan_core/request/mod.rs
1//! Request types and conversion trait for data extractors.
2
3// ----------
4
5use std::future::{ready, Future};
6
7use crate::{body::Body, response::BoxedErrorResponse};
8
9// ----------
10
11pub use http::request::Builder;
12
13// --------------------------------------------------
14
15mod impls;
16
17// --------------------------------------------------------------------------------
18// --------------------------------------------------------------------------------
19
20pub type Request<B = Body> = http::request::Request<B>;
21pub type RequestHeadParts = http::request::Parts;
22
23// --------------------------------------------------
24// FromRequest<B>
25
26/// A trait for extractor types.
27///
28/// Implementors of the `FromRequest` consume the request body and usually convert it
29/// to some form of data.
30pub trait FromRequest<B = Body>: Sized {
31 type Error: Into<BoxedErrorResponse>;
32
33 fn from_request(
34 head_parts: &mut RequestHeadParts,
35 body: B,
36 ) -> impl Future<Output = Result<Self, Self::Error>> + Send;
37}
38
39// --------------------------------------------------------------------------------