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 PR switches the whole library over to
async
.It introduces three new features:
blocking
for stdlib I/Otokio1
for full tokio supportasync-std1
for full async-std supportThe
blocking
feature is essentially abring your own runtime
feature, where standard Rust stdlib I/O functions are used. The behavior will essentially be the same as in the old non-async version of the library, but it still needs an async runtime to run. However, that way it can be used with non-supported async runtimes such assmol
, and theoretically it should also work with thefutures
executor since it doesn't need a reactor.Architectural Concerns
Right now, we're not enabling any feature by default, so when just adding it without any explicitly enabled features, the crate won't compile. I'm not sure that's the best solution, but defaulting to any runtime would require also passing
default-features = false
in addition to the actual feature, so that doesn't sound great either.Update: I think I've found a great way to deal with this. The
default
feature now enables animplicit-blocking
feature, which acts exactly like the explicitblocking
feature, except when eithertokio1
orasync-std1
is present, in which case it acts like it doesn't exist.The code for this is a bit funky, since we have to deal with constructs such as the following:
But that shouldn't really matter. It's not too hard to maintain, and it unlocks a great way of dealing with this.
So, everything is blocking by default now, unless an explicit runtime feature is enabled.