pub fn rust_server() -> redis::RedisResult<()> {
println!("-> redis_server");
let client = redis::Client::open(get_uri())?;
let mut con = client.get_connection()?;
println!("-> redis_server: {}", get_uri());
println!("-> redis_server_pub_sub");
let mut pub_sub = con.as_pubsub();
println!("-> redis_server subscribe channels: {}", get_sub());
pub_sub.subscribe(get_sub())?;
loop {
let msg = pub_sub.get_message()?;
let payload: String = msg.get_payload()?;
println!("{}", payload);
}
}
如何解析以下类型的JSON
有效负载?String
serde_json
let payload: String = msg.get_payload()?;