Coverage Report

Created: 2026-02-14 06:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-1.6.0/src/rt/bounds.rs
Line
Count
Source
1
//! Trait aliases
2
//!
3
//! Traits in this module ease setting bounds and usually automatically
4
//! implemented by implementing another trait.
5
6
#[cfg(all(feature = "server", feature = "http2"))]
7
pub use self::h2::Http2ServerConnExec;
8
9
#[cfg(all(feature = "client", feature = "http2"))]
10
pub use self::h2_client::Http2ClientConnExec;
11
12
#[cfg(all(feature = "client", feature = "http2"))]
13
#[cfg_attr(docsrs, doc(cfg(all(feature = "client", feature = "http2"))))]
14
mod 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
    /// An executor to spawn http2 futures for the client.
21
    ///
22
    /// This trait is implemented for any type that implements [`Executor`]
23
    /// trait for any future.
24
    ///
25
    /// This trait is sealed and cannot be implemented for types outside this crate.
26
    ///
27
    /// [`Executor`]: crate::rt::Executor
28
    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
0
        fn execute_h2_future(&mut self, future: H2ClientFuture<B, T>) {
47
0
            self.execute(future)
48
0
        }
Unexecuted instantiation: <hyper_util::common::exec::Exec as hyper::rt::bounds::h2_client::Http2ClientConnExec<tonic::body::Body, hyper_rustls::stream::MaybeHttpsStream<hyper_util::rt::tokio::TokioIo<tokio::net::tcp::stream::TcpStream>>>>::execute_h2_future
Unexecuted instantiation: <_ as hyper::rt::bounds::h2_client::Http2ClientConnExec<_, _>>::execute_h2_future
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"))))]
68
mod h2 {
69
    use crate::{proto::h2::server::H2Stream, rt::Executor};
70
    use http_body::Body;
71
    use std::future::Future;
72
73
    /// An executor to spawn http2 connections.
74
    ///
75
    /// This trait is implemented for any type that implements [`Executor`]
76
    /// trait for any future.
77
    ///
78
    /// This trait is sealed and cannot be implemented for types outside this crate.
79
    ///
80
    /// [`Executor`]: crate::rt::Executor
81
    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
0
        fn execute_h2stream(&mut self, fut: H2Stream<F, B>) {
94
0
            self.execute(fut)
95
0
        }
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
}