Skip to content

futures-core 1.0 release #2207

Open
Open
@taiki-e

Description

@taiki-e

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.

Changes

Here is a list of proposed actual changes:

  • FusedFuture, FusedStream.
  • Type aliases (BoxFuture, LocalBoxFuture, BoxStream, LocalBoxStream); pending in Move type/trait aliases to futures-util #2344
    • Move to futures-util.
    • They are just type aliases of Pin<Box>ed future/stream.
  • Trait aliases (TryFuture, TryStream); pending in Move type/trait aliases to futures-util #2344
  • 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")


cc @cramertj @Nemo157 @seanmonstar
FYI @rust-lang/wg-async-foundations

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions