hannobraun / inotify-rs

Idiomatic inotify wrapper for the Rust programming language
ISC License
261 stars 65 forks source link

Async runtime agnostic. #201

Closed flukejones closed 2 years ago

flukejones commented 2 years ago

Is it possible to adjust inotfiy streams to be runtime agnostic? All my current work is so far done using smol, and now that I require itnotify I've found I get runtime errors due to no tokio reactor running.

It occurs when I use:

let mut stream = watch.event_stream(&mut buffer).unwrap();
while let Some(e) = stream.next().await {
    // do work
}

or

watch.event_stream(&mut buffer).unwrap().for_each(|_| async {
    // do work
}
hannobraun commented 2 years ago

Hey @flukejones, thank you for opening this issue!

Is it possible

If I interpret your question literally, the answer is, I don't know, but I'd think so? I'm not an expert on async Rust, and my own work has been exclusively with Tokio (for no particular reason, except that it seems to be closest to a "default").

If you're asking if I'd accept a pull request making it so, then yes, happily!

flukejones commented 2 years ago

@hannobraun your first interpretation was correct. I suspect I won't be the only one to come across this, and it looks like it's tied to AsyncFd in tokio so that would be what needs an agnostic version I guess.

If I can find time to work it out I will :)