Nullus157 / async-compression

Adaptors between compression crates and Rust's async IO types

Home Page:https://docs.rs/async-compression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to remove dependency on tokio?

nyurik opened this issue · comments

I'm still learning my way around the async eco, and one of the core features in async is to be able to use different schedulers, in a way that no library actually knows which scheduler is used. Would it be possible to remove the dependencies on a specific async scheduler (tokio) from this code, or is there some fundamental requirement for it in a library? Thanks!

P.S. I guess the proper name for this is for the lib to become "pure async" ?

Well, this library mainly depends on the AsyncRead/AsyncBufRead traits from tokio, it doesn't depend on tokio scheduler to be run.

To remove the dependencies on the AsyncRead trait, you would have to define your own traits and use it here whic is quite complicated thus IMO that's not going to happen.

But, that doesn't mean you cannot use this crate with other async runtime such as async-std.
You just need to bridge their io traits with tokio::io::AsyncRead and it would work fine.

This crate is 100% runtime agnostic, it only (optionally) depends on tokio to provide support for their traits and also (optionally) supports futures-io's traits (which covers the async-std ecosystem). If there were any other major sets of traits it would support those too, but afaik there aren't.