I am trying to figure out how to use a tokio::sync::mpsc::Sender and Receiver within the callbacks on an agent struct.
This works, but does not do anything useful.
blue_agent.display_pin_code = Some(Box::new(|a| {
async move {
println!("Need to display pin code {:?}", a);
a.cancel.await.unwrap();
Ok(())
}
.boxed()
}));
This does not even compile because the compiler complains that s2 does not live long enough.
let s2: tokio::sync::mpsc::Sender<super::MessageToBluetoothHost> = s.clone();
blue_agent.display_passkey = Some(Box::new(|a: DisplayPasskey| {
let s2 = s2.clone();
async move {
let b = async |a: DisplayPasskey| {
s2.send(super::MessageToBluetoothHost::DisplayPasskey(a.passkey)).await;
println!("Need to display passkey {:?}", a);
a.cancel.await.unwrap();
s2.send(super::MessageToBluetoothHost::CancelDisplayPasskey).await;
Ok(())
};
b(a).await
}}
.boxed()));
I am trying to figure out how to use a tokio::sync::mpsc::Sender and Receiver within the callbacks on an agent struct.
This works, but does not do anything useful.
This does not even compile because the compiler complains that s2 does not live long enough.