/rust/registry/src/index.crates.io-1949cf8c6b5b557f/hyper-1.8.1/src/common/either.rs
Line | Count | Source |
1 | | use pin_project_lite::pin_project; |
2 | | use std::{ |
3 | | future::Future, |
4 | | pin::Pin, |
5 | | task::{Context, Poll}, |
6 | | }; |
7 | | |
8 | | pin_project! { |
9 | | /// One of two possible futures that have the same output type. |
10 | | #[project = EitherProj] |
11 | | pub(crate) enum Either<F1, F2> { |
12 | | Left { |
13 | | #[pin] |
14 | | fut: F1 |
15 | | }, |
16 | | Right { |
17 | | #[pin] |
18 | | fut: F2, |
19 | | }, |
20 | | } |
21 | | } |
22 | | |
23 | | impl<F1, F2> Either<F1, F2> { |
24 | 0 | pub(crate) fn left(fut: F1) -> Self { |
25 | 0 | Either::Left { fut } |
26 | 0 | } Unexecuted instantiation: <hyper::common::either::Either<hyper::proto::h2::client::Conn<tonic::transport::channel::service::io::BoxedIo, tonic::body::Body>, h2::client::Connection<hyper::common::io::compat::Compat<tonic::transport::channel::service::io::BoxedIo>, hyper::proto::h2::SendBuf<bytes::bytes::Bytes>>>>::left Unexecuted instantiation: <hyper::common::either::Either<_, _>>::left |
27 | | |
28 | 0 | pub(crate) fn right(fut: F2) -> Self { |
29 | 0 | Either::Right { fut } |
30 | 0 | } Unexecuted instantiation: <hyper::common::either::Either<hyper::proto::h2::client::Conn<tonic::transport::channel::service::io::BoxedIo, tonic::body::Body>, h2::client::Connection<hyper::common::io::compat::Compat<tonic::transport::channel::service::io::BoxedIo>, hyper::proto::h2::SendBuf<bytes::bytes::Bytes>>>>::right Unexecuted instantiation: <hyper::common::either::Either<_, _>>::right |
31 | | } |
32 | | |
33 | | impl<F1, F2> Future for Either<F1, F2> |
34 | | where |
35 | | F1: Future, |
36 | | F2: Future<Output = F1::Output>, |
37 | | { |
38 | | type Output = F1::Output; |
39 | | |
40 | 0 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
41 | 0 | match self.project() { |
42 | 0 | EitherProj::Left { fut } => fut.poll(cx), |
43 | 0 | EitherProj::Right { fut } => fut.poll(cx), |
44 | | } |
45 | 0 | } Unexecuted instantiation: <hyper::common::either::Either<hyper::proto::h2::client::Conn<tonic::transport::channel::service::io::BoxedIo, tonic::body::Body>, h2::client::Connection<hyper::common::io::compat::Compat<tonic::transport::channel::service::io::BoxedIo>, hyper::proto::h2::SendBuf<bytes::bytes::Bytes>>> as core::future::future::Future>::poll Unexecuted instantiation: <hyper::common::either::Either<_, _> as core::future::future::Future>::poll |
46 | | } |