-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unhide tokio_tcp::ConnectFuture? #1346
Comments
If this ends up being a concern, it might be worthwhile looking into other pub apis which have been similarly hidden behind an |
@udoprog are you able to |
Probably at some later point, when people and libraries have acclimated to new usage patterns of async/await. But if we still have a need to embed the named future in places, I don't see why we we should hide it at all. Even with existential types, we'd still have to give it a public name to make it usable. |
Fair point! I think that makes sense and since we don't use |
Why is this true? |
@udoprog the issue is, Tokio is going to be migrating to using |
My bad. I think we'd need to give it a name in our crate, but I guess that depends on how the implementation pans out. EDIT: this playground showcases the issue right now while
Hm. I guess then I'm asking to consider delaying that to give library developers time to adjust: One major release moving to Otherwise the choice for library devs will be boxing or redesigning parts of their code which is doable, but slows down adoption. I do appreciate that it's an undesirable decision. I'm a bit apprehensive in general exposing public functions without the option of capturing their outputs as existential types, since it makes embedding awkward. I don't know if that's viable though. |
@udoprog existential types are basically can be treated as generic arguments. I'm not sure why in first place they had to name it separately, but basically they are not much different from when you have something like But I'm not sure how it is a concern for your public API. |
This reads like a misunderstanding to me, what I wrote was:
So using existential types to capture the output of a function would be fine. I'm saying that I'm wary of exposing public async fns in this library unless something like that exists (in stable Rust). |
Well then we should urge stabilisation of existential types because for async fn it is essential thing, as otherwise we're limiting usage of async await to internals only |
I think the one benefit of keeping it hidden is that it will start forcing people to either use Box or migrate to async/await. If we release two breaking changs 0.2 and 0.3 very shortly after, this will create some unneeded fragmentation. A big reason we are still on tokio 0.1 and not any higher versions. @udoprog does something like boxing work while you wait to rewrite to async fn? |
Interested read this. I hadn't realized
In case it helps, there is the possible middle ground of composing an which composes an Said in words: The author of Apologies if that is already obvious or an uninteresting variant of "migrate to async/await". |
I'm actually bringing this up to avoid fragmentation right now. Pushing people towards structurally rewrite their libraries will be a roadblock to migrate to the next version of Tokio. In my view the nice way to do these sort of things for such a fundamental crate as tokio would be to build new APIs and deprecate old ones over some period of time. Breakage is guaranteed since the Future trait is incompatible. But there's a difference in how painful a migration is between rewriting things locally in place compared to restructuring.
I don't know, I'm not the author of those crates. I'm bringing this up as a papercut I encountered when I tried to upgrade the |
I agree with you on this one, my worry is how much this might hinder us in finding the right api's. I think with such a fundamental change like async/await we are kinda stuck in this spot. I'm not totally sure what the right approach is still :(
@carllerche I'd like to hear your thoughts on this |
tokio 0.2 will sure take a while because it requires async/await stabilization so I think people will have more than enough time |
Exposing the future types will prevent tokio from using async / await. I rather push towards getting libs using async / await. As mentioned, futures can always be boxed to name them. |
"Permit impl Trait in type aliases" RFC merged a couple of days back (rust-lang/rfcs#2515). Still some ways to go before stabilization but encouraging! |
Since #1131
ConnectFuture
is hidden behind animpl Future
. This makes it hard for libraries that embeds it in their custom futures to use since there is no public named type to use.While a custom future should be less used in upcoming apis, it's still a papercut for the initial migration.
For example:
irc
tokio-zookeeper
mysql_async
Can we reintroduce
ConnectFuture
to make it easier for downstream crates to migrate to tokio0.2
when its out?The text was updated successfully, but these errors were encountered: