If you have a Response containing a &str...
#[derive(Serialize, Deserialize, Schema, Debug)]
pub struct InfoResponse<'a> {
pub name: &'a str,
pub mac: [u8; 6],
pub fw_version: (u8, u8, u8),
}
... and try to use this in a std environment with a hostclient...
use std::net::Ipv4Addr;
use postcard_rpc::{host_client::HostClient, standard_icd::WireError};
use std::net::ToSocketAddrs;
use tally_rpc::rpc::{InfoEndpoint, InfoResponse};
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let addr = (Ipv4Addr::new(10, 11, 12, 13), 1234)
.to_socket_addrs()
.unwrap()
.next()
.unwrap();
let cli = HostClient::<WireError>::connect_tcp(addr).await;
println!("connected");
let info: InfoResponse = cli.send_resp::<InfoEndpoint>(&()).await.unwrap();
println!("{:?}", info);
}
...the compiler error you get is misleading, complaining about WireErr:
error: implementation of `serde::de::Deserialize` is not general enough
--> src/bin/tallycli.rs:18:30
|
18 | let info: InfoResponse = cli.send_resp::<InfoEndpoint>(&()).await.unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `serde::de::Deserialize` is not general enough
|
= note: `WireError` must implement `serde::de::Deserialize<'de>`
= note: ...but it actually implements `serde::de::Deserialize<'0>`, for some specific lifetime `'0`
error: implementation of `serde::de::Deserialize` is not general enough
--> src/bin/tallycli.rs:18:34
|
18 | let info: InfoResponse = cli.send_resp::<InfoEndpoint>(&()).await.unwrap();
| ^^^^^^^^^ implementation of `serde::de::Deserialize` is not general enough
|
= note: `WireError` must implement `serde::de::Deserialize<'de>`
= note: ...but it actually implements `serde::de::Deserialize<'0>`, for some specific lifetime `'0`
error: implementation of `serde::de::Deserialize` is not general enough
--> src/bin/tallycli.rs:18:65
|
18 | let info: InfoResponse = cli.send_resp::<InfoEndpoint>(&()).await.unwrap();
| ^^^^^ implementation of `serde::de::Deserialize` is not general enough
|
= note: `WireError` must implement `serde::de::Deserialize<'de>`
= note: ...but it actually implements `serde::de::Deserialize<'0>`, for some specific lifetime `'0`
error: could not compile `tool` (bin "tallycli") due to 3 previous errors
If you have a Response containing a
&str...... and try to use this in a
stdenvironment with a hostclient......the compiler error you get is misleading, complaining about WireErr: