Skip to content
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

io: remove bytes dependency from the tokio public API #2735

Closed
carllerche opened this issue Jul 31, 2020 · 1 comment
Closed

io: remove bytes dependency from the tokio public API #2735

carllerche opened this issue Jul 31, 2020 · 1 comment
Labels
A-tokio Area: The main tokio crate C-proposal Category: a proposal and request for comments M-io Module: tokio/io
Milestone

Comments

@carllerche
Copy link
Member

Summary

The bytes crate is not yet at 1.0. Removing bytes from the Tokio public API will enable us to ship faster. It will also allow both bytes and Tokio to experiment with additional potential APIs before stabilizing. Any utility currently in tokio that uses bytes types as part of the public API is moved to tokio-util.

Motivation

Tokio aims to release 1.0 by the end of 2020. Any type from external crates available as part of the Tokio public API must follow the same guarantees as Toko. The bytes crate is not currently at a 1.0. While we could attempt to reach a bytes 1.0 release, doing so is risky for a few reasons.

Removing bytes as a public dependency for the initial 1.0 release would be relatively straightforward as it is not used as #2716 proposes to remove it from the main core API.

Proposal

All utilities that use bytes are moved to tokio-util until they can be stabilized. This includes:

  • AsyncRead::read_buf
  • AsyncWrite::write_buf
  • Stream::collect() for bytes types.
  • stream_reader

AsyncReadExt and AsyncWriteExt traits are added to tokio-util (read / write helpers in tokio are moved to AsyncRead / AsyncWrite proper).

The loss of StreamExt::collect will be the most immediately impactful. We could add StreamExt::collect_buf() (naming TBD) in tokio-util.

@carllerche carllerche added C-proposal Category: a proposal and request for comments A-tokio Area: The main tokio crate labels Jul 31, 2020
@carllerche carllerche added this to the v1.0 milestone Jul 31, 2020
@carllerche carllerche mentioned this issue Jul 31, 2020
10 tasks
@taiki-e taiki-e added the M-io Module: tokio/io label Oct 7, 2020
@carllerche
Copy link
Member Author

Instead of avoiding bytes, we are going to release bytes 1.0 and depend on that.

Refs: #3058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-proposal Category: a proposal and request for comments M-io Module: tokio/io
Projects
None yet
Development

No branches or pull requests

2 participants