http_request_validator/
lib.rs1#![no_std]
4
5pub trait Validator<Data: bytes::Buf> {
13 type Error;
15
16 fn validate<'a>(
18 &'a self,
19 parts: &'a http::request::Parts,
20 buffered_body: &'a Data,
21 ) -> impl core::future::Future<Output = Result<(), Self::Error>> + Send + 'a;
22}
23
24impl<T: ?Sized, Data> Validator<Data> for T
25where
26 T: core::ops::Deref + Send + Sync,
27 <T as core::ops::Deref>::Target: Validator<Data> + Send,
28 Data: bytes::Buf + Send + Sync,
29{
30 type Error = <<T as core::ops::Deref>::Target as Validator<Data>>::Error;
31
32 fn validate<'a>(
33 &'a self,
34 parts: &'a http::request::Parts,
35 buffered_body: &'a Data,
36 ) -> impl core::future::Future<Output = Result<(), Self::Error>> + 'a {
37 self.deref().validate(parts, buffered_body)
38 }
39}