EventStream
is not Send
#284
-
Good morning! I'm currently trying to create an application with a client-server architecture that needs to read from an
Since I can't seem to understand why is it the case, do you think its implementation can be changed into something that is For reference, here is the code that generated the error: async fn server() -> anyhow::Result<()> {
let (tx, rx) = broadcast::channel(100);
log::info!("Launching Hyprland IPC Reader...");
tokio::spawn(HyprlandIPCReader::setup(tx).event_loop());
log::info!("Launching Client Acceptor...");
ClientAcceptor::init(rx)?.main_loop().await
} use futures_lite::StreamExt;
use hyprland::event_listener::{Event, EventStream};
use tokio::sync::broadcast::Sender;
pub struct HyprlandIPCReader {
channel: Sender<Event>,
event_stream: EventStream
}
impl HyprlandIPCReader {
pub fn setup(channel: Sender<Event>) -> Self {
let event_stream = EventStream::new();
Self { channel, event_stream }
}
pub async fn event_loop(mut self) -> anyhow::Result<()> {
self.event_stream.try_for_each(|event| -> anyhow::Result<()> {
self.channel.send(event?)?;
Ok(())
}).await
}
} Thank you very much for your time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is not |
Beta Was this translation helpful? Give feedback.
It is not
Send
because theStream
trait object it has, is not limited to beSend
feel free to change this in a PR by making it
+ Send
.