Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This goes some of the way towards taking care of #51 though right now just for linux-native as it's the easiest to do (at least for me).
Doing async through traits can be a bit challenging. I played around with methods returning boxed futures but then you start having to care about the lifetimes of the buffers and those go into the signatures and it gets ugly.
Which is why I went with how everyone else does it, which is to have a
poll_{read,write}method. We then usefutures::poll_fnto make a future out of that.As far as choosing which runtime flavour to use (given you can't go fully generic without implementing a bunch more things that the runtimes give you), I ended up going for both major ones as it was pretty easy to implement them both. The tokio variant works if you're using tokio without extra dependencies, and the smol/async-io version works wherever.
Unfortunately this is quite an explosion of feature flags to enable the user of the library to say what stack they're working on, but I don't know of a way to auto-select depending on what else is selected in a dependent project. And I haven't even tackled what happens if you want async but also basic-udev.
One thing I'm not sure here is the naming of the generic
asyncfeature as you're not meant to enable it yourself, but rather choose a backend. Maybe it should be__asyncto indicate it's internal. This is e.g. what I've seenreqwestdoes.