I have a gRPC server and need to make a HTTP GET. I'm struggling getting the futures right in the calls.
I'm trying this
fn current(
&self,
_: ::grpc::RequestOptions,
p: quote::CurrentRequest,
) -> ::grpc::SingleResponse<quote::CurrentResponse> {
let symbol = p.get_symbol();
let client = Client::new();
let fut: grpc::GrpcFuture<quote::CurrentResponse> = Box::new(
client
.get(Uri::from_static(AlphaFunction::base_url()))
.and_then(|res| res.into_body().concat2())
.and_then(|body| {
info!("body {:?}", body);
let mut r = quote::CurrentResponse::new();
// TODO: Parse body
r.set_symbol(symbol.to_string());
Ok(r)
})
.map_err(|e| e),
);
grpc::SingleResponse::new(fut)
}
But I get a bunch of errors:
expected struct `hyper::error::Error`, found enum `grpc::error::Error`
and
77 | grpc::SingleResponse::new(fut)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `protos::quote::CurrentResponse`, found tuple