-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using the crate without tokio #43
Conversation
I've also added tests for no-default-features and also cargo clippy checks. This PR should not affect existing users. If it does, it is a bug. |
Though this is not a goal of this crate (because it is named after tokio-socks), it's possible to use it under other async runtimes even now.
Therefore, I don't want to include the compat layer directly in this crate because it's actually unnecessary and out of the scope of the crate. Nevertheless, I think it okay to make |
For my use case, there are teams that just do not want Making Also, I believe that the refactor I proposed is actually cleanly organized. Each of the original I've also added clippy in CI to ensure that the code is clean for different feature sets. |
I see you're contributing to zed. I think it's not true for their case. Tokio exists in their codebase. They just don't use the tokio runtime (and its network parts of course). It's quite common to use tokio not for their runtime. For example, it's clean to import tokio only for its synchronization primitives like Mutex or Semaphore. It should be the similar case for this crate. Tokio with only |
Okay. What do you think about this idea? Since I also find feature gates a bit nasty as they have to be additive, what if we don't use features to do this? We can change the repo into a rust workspace, where the old "tokio-socks" package does its job for tokio and keeps its API unchanged, while we refactor the core functionality to use traits from futures-io (it just strikes me that futures-io and tokio/io are almost drop-in replacement for each other in the most difficult core part of the crate) and place that into another package in the same workspace. Then use Compat to wrap it for tokio-socks crate. This way we don't have to worry about the nasty feature gates. What do you think?😁 If you find this promising, I can close this PR and work on it. Basically so we can publish two crates using the same core code. |
Right... I'm particularly not a fan of mutual exclusive features. It's a huge mess for users. This is the commit of my scratch code of the solution: eb2e5f7 We can create our own IO trait. And by default, the trait is implemented for tokio IO types to keep backward compatibility. Users can wrap futures-io types with the |
That's a very nice solution! Great! It makes the features no longer conflicting each other. |
I think I can help furnish tests, clippy & formatting by PR to compat branch. If you need this, you can tell me. |
You can continue with my code and that would be great. |
Okay, let me give it a try. Closing this one. |
Previously the crate requires tokio. This PR makes tokio optional behind a default feature gate
tokio
. Now, when using this crate with--no-default
, it can be used with other runtimes such asasync-std
andsmol
without depending on tokio.This PR does not affect the old users since
tokio
is enabled by default.Closes #42