Can anyone tell what the lifetime error is in the following code? (simplified from my actual code) I've looked it over myself, but I can't figure out what is wrong or how to fix it.
use crate::hello_world_capnp::hello_world;
use capnp_rpc::{rpc_twoparty_capnp, twoparty, RpcSystem};
use futures::AsyncReadExt;
use futures::FutureExt;
use std;
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio::task::LocalSet::new()
.run_until(async move {
let stream = tokio::net::TcpStream::connect("").await?;
stream.set_nodelay(true)?;
let (reader, writer) =
tokio_util::compat::TokioAsyncReadCompatExt::compat(stream).split();
let rpc_network = Box::new(twoparty::VatNetwork::new(
reader,
writer,
rpc_twoparty_capnp::Side::Client,
Default::default(),
));
let mut rpc_system = RpcSystem::new(rpc_network, None);
let hello_world: hello_world::Client =
rpc_system.bootstrap(rpc_twoparty_capnp::Side::Server);
tokio::task::spawn_local(Box::pin(rpc_system.map(|_| ())));
let mut request = hello_world.say_hello_request();
request.get().init_request().set_name("name");
let reply = request.send().promise.await.unwrap();
let img = reply
.get()
.unwrap()
.get_reply()
.unwrap()
.get_image()
.unwrap();
show_image::run_context(move || {
let image = ImageView::new(ImageInfo::rgb8(800, 533), img.clone());
});
Ok(())
})
.await
}
The compiler error is
`reply` does not live long enough
borrowed value does not live long enough