Coverage Report

Created: 2026-07-13 08:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-1.9.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 = "client", feature = "http2"))]
7
pub use self::h2_client::Http2ClientConnExec;
8
#[cfg(all(feature = "server", feature = "http2"))]
9
pub use self::h2_server::Http2ServerConnExec;
10
11
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
12
pub(crate) use self::h2_common::Http2UpgradedExec;
13
14
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
15
mod h2_common {
16
    use crate::proto::h2::upgrade::UpgradedSendStreamTask;
17
    use crate::rt::Executor;
18
19
    pub trait Http2UpgradedExec<B> {
20
        #[doc(hidden)]
21
        fn execute_upgrade(&self, fut: UpgradedSendStreamTask<B>);
22
    }
23
24
    #[doc(hidden)]
25
    impl<E, B> Http2UpgradedExec<B> for E
26
    where
27
        E: Executor<UpgradedSendStreamTask<B>>,
28
    {
29
0
        fn execute_upgrade(&self, fut: UpgradedSendStreamTask<B>) {
30
0
            self.execute(fut)
31
0
        }
Unexecuted instantiation: <tonic::transport::channel::service::executor::SharedExec as hyper::rt::bounds::h2_common::Http2UpgradedExec<bytes::bytes::Bytes>>::execute_upgrade
Unexecuted instantiation: <_ as hyper::rt::bounds::h2_common::Http2UpgradedExec<_>>::execute_upgrade
32
    }
33
}
34
35
#[cfg(all(feature = "client", feature = "http2"))]
36
#[cfg_attr(docsrs, doc(cfg(all(feature = "client", feature = "http2"))))]
37
mod h2_client {
38
    use std::{error::Error, future::Future};
39
40
    use crate::rt::{Read, Write};
41
    use crate::{proto::h2::client::H2ClientFuture, rt::Executor};
42
43
    /// An executor to spawn http2 futures for the client.
44
    ///
45
    /// This trait is implemented for any type that implements [`Executor`]
46
    /// trait for any future.
47
    ///
48
    /// This trait is sealed and cannot be implemented for types outside this crate.
49
    ///
50
    /// [`Executor`]: crate::rt::Executor
51
    pub trait Http2ClientConnExec<B, T>:
52
        super::Http2UpgradedExec<B::Data> + sealed_client::Sealed<(B, T)> + Clone
53
    where
54
        B: http_body::Body,
55
        B::Error: Into<Box<dyn Error + Send + Sync>>,
56
        T: Read + Write + Unpin,
57
    {
58
        #[doc(hidden)]
59
        fn execute_h2_future(&mut self, future: H2ClientFuture<B, T, Self>);
60
    }
61
62
    impl<E, B, T> Http2ClientConnExec<B, T> for E
63
    where
64
        E: Clone,
65
        E: Executor<H2ClientFuture<B, T, E>>,
66
        E: super::Http2UpgradedExec<B::Data>,
67
        B: http_body::Body + 'static,
68
        B::Error: Into<Box<dyn Error + Send + Sync>>,
69
        H2ClientFuture<B, T, E>: Future<Output = ()>,
70
        T: Read + Write + Unpin,
71
    {
72
0
        fn execute_h2_future(&mut self, future: H2ClientFuture<B, T, E>) {
73
0
            self.execute(future)
74
0
        }
Unexecuted instantiation: <tonic::transport::channel::service::executor::SharedExec as hyper::rt::bounds::h2_client::Http2ClientConnExec<tonic::body::Body, tonic::transport::channel::service::io::BoxedIo>>::execute_h2_future
Unexecuted instantiation: <_ as hyper::rt::bounds::h2_client::Http2ClientConnExec<_, _>>::execute_h2_future
75
    }
76
77
    impl<E, B, T> sealed_client::Sealed<(B, T)> for E
78
    where
79
        E: Clone,
80
        E: Executor<H2ClientFuture<B, T, E>>,
81
        E: super::Http2UpgradedExec<B::Data>,
82
        B: http_body::Body + 'static,
83
        B::Error: Into<Box<dyn Error + Send + Sync>>,
84
        H2ClientFuture<B, T, E>: Future<Output = ()>,
85
        T: Read + Write + Unpin,
86
    {
87
    }
88
89
    mod sealed_client {
90
        pub trait Sealed<X> {}
91
    }
92
}
93
94
#[cfg(all(feature = "server", feature = "http2"))]
95
#[cfg_attr(docsrs, doc(cfg(all(feature = "server", feature = "http2"))))]
96
mod h2_server {
97
    use crate::{proto::h2::server::H2Stream, rt::Executor};
98
    use http_body::Body;
99
    use std::future::Future;
100
101
    /// An executor to spawn http2 connections.
102
    ///
103
    /// This trait is implemented for any type that implements [`Executor`]
104
    /// trait for any future.
105
    ///
106
    /// This trait is sealed and cannot be implemented for types outside this crate.
107
    ///
108
    /// [`Executor`]: crate::rt::Executor
109
    pub trait Http2ServerConnExec<F, B: Body>:
110
        super::Http2UpgradedExec<B::Data> + sealed::Sealed<(F, B)> + Clone
111
    {
112
        #[doc(hidden)]
113
        fn execute_h2stream(&mut self, fut: H2Stream<F, B, Self>);
114
    }
115
116
    #[doc(hidden)]
117
    impl<E, F, B> Http2ServerConnExec<F, B> for E
118
    where
119
        E: Clone,
120
        E: Executor<H2Stream<F, B, E>>,
121
        E: super::Http2UpgradedExec<B::Data>,
122
        H2Stream<F, B, E>: Future<Output = ()>,
123
        B: Body,
124
    {
125
0
        fn execute_h2stream(&mut self, fut: H2Stream<F, B, E>) {
126
0
            self.execute(fut)
127
0
        }
128
    }
129
130
    impl<E, F, B> sealed::Sealed<(F, B)> for E
131
    where
132
        E: Clone,
133
        E: Executor<H2Stream<F, B, E>>,
134
        E: super::Http2UpgradedExec<B::Data>,
135
        H2Stream<F, B, E>: Future<Output = ()>,
136
        B: Body,
137
    {
138
    }
139
140
    mod sealed {
141
        pub trait Sealed<T> {}
142
    }
143
}