1use core::fmt;
2
3use xitca_service::Service;
4
5use crate::builder::{HttpServiceBuilder, marker};
6
7use super::service::H1Service;
8
9impl<St, FA, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize>
10 HttpServiceBuilder<marker::Http1, marker::Poll, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
11{
12 #[cfg(unix)]
13 pub fn unix(
15 self,
16 ) -> HttpServiceBuilder<
17 marker::Http1,
18 marker::Poll,
19 xitca_io::net::UnixStream,
20 FA,
21 HEADER_LIMIT,
22 READ_BUF_LIMIT,
23 WRITE_BUF_LIMIT,
24 >
25 where
26 FA: Service,
27 {
28 HttpServiceBuilder {
29 tls_factory: self.tls_factory,
30 config: self.config,
31 _body: std::marker::PhantomData,
32 }
33 }
34
35 #[cfg(feature = "io-uring")]
36 pub fn io_uring(
38 self,
39 ) -> HttpServiceBuilder<
40 marker::Http1,
41 marker::Uring,
42 xitca_io::net::io_uring::TcpStream,
43 FA,
44 HEADER_LIMIT,
45 READ_BUF_LIMIT,
46 WRITE_BUF_LIMIT,
47 >
48 where
49 FA: Service,
50 {
51 HttpServiceBuilder {
52 tls_factory: self.tls_factory,
53 config: self.config,
54 _body: std::marker::PhantomData,
55 }
56 }
57}
58
59type Error = Box<dyn fmt::Debug>;
60
61impl<St, Io, FA, S, E, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize>
62 Service<Result<S, E>>
63 for HttpServiceBuilder<marker::Http1, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
64where
65 FA: Service,
66 FA::Error: fmt::Debug + 'static,
67 E: fmt::Debug + 'static,
68{
69 type Response = H1Service<St, Io, S, FA::Response, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>;
70 type Error = Error;
71
72 async fn call(&self, res: Result<S, E>) -> Result<Self::Response, Self::Error> {
73 let service = res.map_err(|e| Box::new(e) as Error)?;
74 let tls_acceptor = self.tls_factory.call(()).await.map_err(|e| Box::new(e) as Error)?;
75 Ok(H1Service::new(self.config, service, tls_acceptor))
76 }
77}