1#[cfg(all(feature = "server", feature = "http2"))]
7pub use self::h2::Http2ServerConnExec;
8
9#[cfg(all(feature = "client", feature = "http2"))]
10pub use self::h2_client::Http2ClientConnExec;
11
12#[cfg(all(feature = "client", feature = "http2"))]
13#[cfg_attr(docsrs, doc(cfg(all(feature = "client", feature = "http2"))))]
14mod h2_client {
15 use std::{error::Error, future::Future};
16
17 use crate::rt::{Read, Write};
18 use crate::{proto::h2::client::H2ClientFuture, rt::Executor};
19
20 pub trait Http2ClientConnExec<B, T>: sealed_client::Sealed<(B, T)>
29 where
30 B: http_body::Body,
31 B::Error: Into<Box<dyn Error + Send + Sync>>,
32 T: Read + Write + Unpin,
33 {
34 #[doc(hidden)]
35 fn execute_h2_future(&mut self, future: H2ClientFuture<B, T>);
36 }
37
38 impl<E, B, T> Http2ClientConnExec<B, T> for E
39 where
40 E: Executor<H2ClientFuture<B, T>>,
41 B: http_body::Body + 'static,
42 B::Error: Into<Box<dyn Error + Send + Sync>>,
43 H2ClientFuture<B, T>: Future<Output = ()>,
44 T: Read + Write + Unpin,
45 {
46 fn execute_h2_future(&mut self, future: H2ClientFuture<B, T>) {
47 self.execute(future)
48 }
49 }
50
51 impl<E, B, T> sealed_client::Sealed<(B, T)> for E
52 where
53 E: Executor<H2ClientFuture<B, T>>,
54 B: http_body::Body + 'static,
55 B::Error: Into<Box<dyn Error + Send + Sync>>,
56 H2ClientFuture<B, T>: Future<Output = ()>,
57 T: Read + Write + Unpin,
58 {
59 }
60
61 mod sealed_client {
62 pub trait Sealed<X> {}
63 }
64}
65
66#[cfg(all(feature = "server", feature = "http2"))]
67#[cfg_attr(docsrs, doc(cfg(all(feature = "server", feature = "http2"))))]
68mod h2 {
69 use crate::{proto::h2::server::H2Stream, rt::Executor};
70 use http_body::Body;
71 use std::future::Future;
72
73 pub trait Http2ServerConnExec<F, B: Body>: sealed::Sealed<(F, B)> + Clone {
82 #[doc(hidden)]
83 fn execute_h2stream(&mut self, fut: H2Stream<F, B>);
84 }
85
86 #[doc(hidden)]
87 impl<E, F, B> Http2ServerConnExec<F, B> for E
88 where
89 E: Executor<H2Stream<F, B>> + Clone,
90 H2Stream<F, B>: Future<Output = ()>,
91 B: Body,
92 {
93 fn execute_h2stream(&mut self, fut: H2Stream<F, B>) {
94 self.execute(fut)
95 }
96 }
97
98 impl<E, F, B> sealed::Sealed<(F, B)> for E
99 where
100 E: Executor<H2Stream<F, B>> + Clone,
101 H2Stream<F, B>: Future<Output = ()>,
102 B: Body,
103 {
104 }
105
106 mod sealed {
107 pub trait Sealed<T> {}
108 }
109}