我有一个gRPC服务器,需要进行HTTP GET。我正在努力在电话中正确选择期货。
我正在尝试
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)
}
但是我遇到了很多错误:
expected struct `hyper::error::Error`, found enum `grpc::error::Error`
和
77 | grpc::SingleResponse::new(fut)
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `protos::quote::CurrentResponse`, found tuple
答案 0 :(得分:-1)
我知道了:
let fut = client
.get(Uri::from_static(AlphaFunction::base_url()))
.and_then(|res| res.into_body().concat2())
.and_then(move |body| {
info!("body {:?}", body);
let mut r = quote::CurrentResponse::new();
r.set_symbol(symbol.to_string());
Ok(r)
})
.map_err(|e| grpc::Error::Panic(format!("{}", e)));