You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposal for the next major release of futures-core.
(I will open issues for other crates later. They are probably 0.4 instead of 1.0.)
About
I propose to further reduce the APIs of futures-core and only provide what is really stable.
This makes futures-core a shim crate that provides future/task-related APIs of the standard library.
Eventually (maybe after core::stream::Stream stabilized), only crates that need compatibility with older compilers will depend on futures-core, and other crates will not need to depend on futures-core.
APIs provided by this crate
The following two kinds of APIs are provided:
APIs already stable in the standard library:
In versions where it is stable, re-export from the standard library
In versions where it doesn't exist in the standard library or isn't stable yet, futures-core defines & provides the same (use build-script to detect it).
This allows you to use items that are only available in the latest rustc, even if you are using an older version of rustc.
APIs not yet stable in the standard library:
If we know what (definition of items) will be added to the standard library, we can define and provide the same until it stabilizes.
However, basically do not add at this stage.
Stream trait and ready! macro are probably the only exceptions to this.
Once stable, we can re-export with later versions (use build-script to detect it).
Other APIs are provided by individual futures-* crate.
MSRV
APIs of this crate is really small, so it would be nice to be able to pin it to one of the following:
Rust 1.36 that future/task-api stabilized.
Rust 1.39 that async-await stabilized.
Every time the MSRV is increased, a new minor version is released.
They are just trait aliases of future/stream that return Result, but the real trait aliases are not yet stable, so they have some limitations. See doc: calling TryStreamExt methods on !Unpin values #2200 for one of the limitations.
Stream trait
Once the std Stream trait is stable, futures_core::Stream is replaced with re-export from the standard library. (In the version that has stable std Stream, std Stream and futures_core::Stream is the same trait.) * Add next method from StreamExt.
This may depend on the decisions of @rust-lang/wg-async-foundations or other teams. (As much as possible, I'd like to avoid the situation where the API of Stream changes after futures-core 1.0 is released.)
Do not add other methods from StreamExt/TryStreamExt. There is no general agreement on those APIs. Especialy, async closure vs normal closure.
ready! macro
as-is
This is still unstable in the standard library, but I don't think the API itself will change.
The standard library's ready! macro maybe core::task::ready! instead of core::ready!, but futures-core expose this at top-revel. Because:
To do the same requires an unstable feature.
Unlike the standard library, futures-core provides only future/task-related items.
Wake trait
Currently named as ArcWake, and defined in futures-task.
Once core::task::Wake trait stable, re-export/define in futures-core.
From-impl may not be available in the old version, so provide conversion utilities (waker, waker_ref) in futures-task or futures-util.
Other utilities in std::{future, task, stream}
Once stable, re-exported/defined in futures-core.
And re-exported in futures-util. (Be careful with minimal-versions to avoid compile failure.)
EDIT1: Clarified futures_core::Stream changes when std Stream is stable. (originally only described in "about" section's "APIs not yet stable in the standard library")
This is a proposal for the next major release of futures-core.
(I will open issues for other crates later. They are probably 0.4 instead of 1.0.)
About
I propose to further reduce the APIs of futures-core and only provide what is really stable.
This makes futures-core a shim crate that provides future/task-related APIs of the standard library.
Eventually (maybe after
core::stream::Streamstabilized), only crates that need compatibility with older compilers will depend on futures-core, and other crates will not need to depend on futures-core.APIs provided by this crate
The following two kinds of APIs are provided:
This allows you to use items that are only available in the latest rustc, even if you are using an older version of rustc.
Streamtrait andready!macro are probably the only exceptions to this.Other APIs are provided by individual
futures-*crate.MSRV
APIs of this crate is really small, so it would be nice to be able to pin it to one of the following:
Every time the MSRV is increased, a new minor version is released.
Changes
Here is a list of proposed actual changes:
FusedFuture,FusedStream.select!macro is replaced with the way suggested in select! without FusedFuture #1989.BoxFuture,LocalBoxFuture,BoxStream,LocalBoxStream); pending in Move type/trait aliases to futures-util #2344futures-util.Pin<Box>ed future/stream.TryFuture,TryStream); pending in Move type/trait aliases to futures-util #2344futures-util.Result, but the real trait aliases are not yet stable, so they have some limitations. See doc: calling TryStreamExt methods on !Unpin values #2200 for one of the limitations.StreamtraitStreamtrait is stable,futures_core::Streamis replaced with re-export from the standard library. (In the version that has stable std Stream, std Stream and futures_core::Stream is the same trait.)* Addnextmethod fromStreamExt.Streamchanges after futures-core 1.0 is released.)StreamExt/TryStreamExt. There is no general agreement on those APIs. Especialy, async closure vs normal closure.ready!macroready!macro maybecore::task::ready!instead ofcore::ready!, butfutures-coreexpose this at top-revel.Because:
futures-coreprovides only future/task-related items.WaketraitArcWake, and defined infutures-task.core::task::Waketrait stable, re-export/define infutures-core.From-impl may not be available in the old version, so provide conversion utilities (waker,waker_ref) infutures-taskorfutures-util.std::{future, task, stream}futures-core.futures-util. (Be careful with minimal-versions to avoid compile failure.)EDIT1: Clarified
futures_core::Streamchanges when stdStreamis stable. (originally only described in "about" section's "APIs not yet stable in the standard library")cc @cramertj @Nemo157 @seanmonstar
FYI @rust-lang/wg-async-foundations