1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::client_streaming;
use crate::error::Error;
use crate::Body;
use futures::{stream, Future, Poll};
use http::Response;
use prost::Message;
use std::fmt;
pub struct ResponseFuture<T, U, B: Body> {
inner: client_streaming::ResponseFuture<T, U, B>,
}
pub type Once<T> = stream::Once<T, crate::Status>;
impl<T, U, B: Body> ResponseFuture<T, U, B> {
pub(crate) fn new(inner: client_streaming::ResponseFuture<T, U, B>) -> Self {
ResponseFuture { inner }
}
}
impl<T, U, B> Future for ResponseFuture<T, U, B>
where
T: Message + Default,
U: Future<Item = Response<B>>,
U::Error: Into<Error>,
B: Body,
B::Error: Into<Error>,
{
type Item = crate::Response<T>;
type Error = crate::Status;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
self.inner.poll()
}
}
impl<T, U, B> fmt::Debug for ResponseFuture<T, U, B>
where
T: fmt::Debug,
U: fmt::Debug,
B: Body + fmt::Debug,
B::Data: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ResponseFuture")
.field("inner", &self.inner)
.finish()
}
}