tower_web/util/buf_stream/
either.rs

1use super::{BufStream, SizeHint};
2use futures::{future::Either, Poll};
3
4impl<A, B> BufStream for Either<A, B>
5where
6    A: BufStream,
7    B: BufStream<Item = A::Item, Error = A::Error>,
8{
9    type Item = A::Item;
10    type Error = A::Error;
11
12    fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
13        match self {
14            Either::A(a) => a.poll(),
15            Either::B(b) => b.poll(),
16        }
17    }
18
19    fn size_hint(&self) -> SizeHint {
20        match self {
21            Either::A(a) => a.size_hint(),
22            Either::B(b) => b.size_hint(),
23        }
24    }
25}