use actix::prelude::*;
use actix_web::{
get,
web::{Json, Data},
App, HttpServer,
};
use serde::{Deserialize};
use redis_async::{
resp_array,
resp::{RespValue, FromResp},
client::paired::PairedConnection as RedisConn
};
use std::str::FromStr;
use std::net::SocketAddr;
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
let redis = redis_async::client::paired::paired_connect(&SocketAddr::from_str("127.0.0.1:6379").unwrap()).await.unwrap();
HttpServer::new(move || {
App::new()
.wrap(actix_web::middleware::Logger::new(
"%a \"%r\" Response: %s %b",
))
.data(redis.clone())
.service(get_health)
})
.bind("127.0.0.1:8088")?
.start()
.await
}
impl<'a, T: Deserialize<'a>> FromResp for T {
fn from_resp_int(resp: RespValue) -> Result<T, redis_async::error::Error> {
unimplemented!()
}
}
#[get("/admin/v1/health")]
async fn get_health(redis: Data<RedisConn>) -> Json<usize> {
let res = redis.send::<String>(resp_array!["PING"]).await;
Json(0)
}
It yields this weird error:
error[E0283]: type annotations required: cannot resolve `std::string::String: redis_async::resp::FromResp`
--> src/main.rs:43:21
|
43 | let res = redis.send::<String>(resp_array!["PING"]).await;
| ^^^^
error: aborting due to previous error
Whereas the real error is impl<'a, T: Deserialize<'a>> FromResp for T. If I remove that impl block, it's all fine.
I have a minimal example, using stable rustc 1.39.0:
Cargo.toml
:main.rs
:It yields this weird error:
Whereas the real error is
impl<'a, T: Deserialize<'a>> FromResp for T
. If I remove that impl block, it's all fine.