/rust/registry/src/index.crates.io-6f17d22bba15001f/hyper-1.6.0/src/service/http.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use std::error::Error as StdError; |
2 | | use std::future::Future; |
3 | | |
4 | | use crate::body::Body; |
5 | | use crate::service::service::Service; |
6 | | use crate::{Request, Response}; |
7 | | |
8 | | /// An asynchronous function from `Request` to `Response`. |
9 | | pub trait HttpService<ReqBody>: sealed::Sealed<ReqBody> { |
10 | | /// The `Body` body of the `http::Response`. |
11 | | type ResBody: Body; |
12 | | |
13 | | /// The error type that can occur within this `Service`. |
14 | | /// |
15 | | /// Note: Returning an `Error` to a hyper server will cause the connection |
16 | | /// to be abruptly aborted. In most cases, it is better to return a `Response` |
17 | | /// with a 4xx or 5xx status code. |
18 | | type Error: Into<Box<dyn StdError + Send + Sync>>; |
19 | | |
20 | | /// The `Future` returned by this `Service`. |
21 | | type Future: Future<Output = Result<Response<Self::ResBody>, Self::Error>>; |
22 | | |
23 | | #[doc(hidden)] |
24 | | fn call(&mut self, req: Request<ReqBody>) -> Self::Future; |
25 | | } |
26 | | |
27 | | impl<T, B1, B2> HttpService<B1> for T |
28 | | where |
29 | | T: Service<Request<B1>, Response = Response<B2>>, |
30 | | B2: Body, |
31 | | T::Error: Into<Box<dyn StdError + Send + Sync>>, |
32 | | { |
33 | | type ResBody = B2; |
34 | | |
35 | | type Error = T::Error; |
36 | | type Future = T::Future; |
37 | | |
38 | 0 | fn call(&mut self, req: Request<B1>) -> Self::Future { |
39 | 0 | Service::call(self, req) |
40 | 0 | } Unexecuted instantiation: <hyper::service::util::ServiceFn<<ztunnel::hyper_util::Server<std::sync::mutex::Mutex<prometheus_client::registry::Registry>>>::spawn<<ztunnel::metrics::server::Server>::spawn::{closure#0}, <ztunnel::metrics::server::Server>::spawn::{closure#0}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}, hyper::body::incoming::Incoming> as hyper::service::http::HttpService<hyper::body::incoming::Incoming>>::call Unexecuted instantiation: <hyper::service::util::ServiceFn<<ztunnel::hyper_util::Server<ztunnel::admin::State>>::spawn<<ztunnel::admin::Service>::spawn::{closure#0}, <ztunnel::admin::Service>::spawn::{closure#0}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}, hyper::body::incoming::Incoming> as hyper::service::http::HttpService<hyper::body::incoming::Incoming>>::call Unexecuted instantiation: <hyper::service::util::ServiceFn<<ztunnel::hyper_util::Server<ztunnel::readiness::Ready>>::spawn<<ztunnel::readiness::server::Server>::spawn::{closure#0}, <ztunnel::readiness::server::Server>::spawn::{closure#0}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}, hyper::body::incoming::Incoming> as hyper::service::http::HttpService<hyper::body::incoming::Incoming>>::call Unexecuted instantiation: <_ as hyper::service::http::HttpService<_>>::call |
41 | | } |
42 | | |
43 | | impl<T, B1, B2> sealed::Sealed<B1> for T |
44 | | where |
45 | | T: Service<Request<B1>, Response = Response<B2>>, |
46 | | B2: Body, |
47 | | { |
48 | | } |
49 | | |
50 | | mod sealed { |
51 | | pub trait Sealed<T> {} |
52 | | } |