http_body_request_validator/bufferer.rs
1//! [`Bufferer`] trait and utils.
2
3/// The ability to buffer and validate an [`http_body::Body`].
4pub trait Bufferer<InBody: http_body::Body> {
5 /// The buffered body type.
6 type Buffered: crate::AsBuf;
7
8 /// An error that can occur while buffering.
9 type Error;
10
11 /// Buffer the given body into [`Self::Buffered`].
12 fn buffer(
13 &self,
14 body: InBody,
15 ) -> impl core::future::Future<Output = Result<Self::Buffered, Self::Error>>;
16}
17
18/// Extract bufferer buffered type.
19pub type BufferedFor<Bufferer, InBody> = <Bufferer as self::Bufferer<InBody>>::Buffered;
20
21/// Extract bufferer data type.
22pub type DataFor<Bufferer, InBody> = <BufferedFor<Bufferer, InBody> as crate::AsBuf>::Data;