Skip to content

Re-export IO traits from futures #224

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

Merged
merged 11 commits into from Sep 22, 2019
Merged

Re-export IO traits from futures #224

merged 11 commits into from Sep 22, 2019

Conversation

ghost
Copy link

@ghost ghost commented Sep 21, 2019

Sorry for the big PR!

Instead of providing our own traits async_std::io::{Read, Write, Seek, BufRead}, we now re-export futures::io::{AsyncRead, AsyncWrite, AsyncSeek, AsyncRead}. While re-exporting we rename them to strip away the "Async" prefix.

The documentation will display the contents of the original traits from the futures crate together with our own extension methods. There's a note in the docs saying the extenion methods become available only when async_std::prelude::* is imported.

Our extension traits are re-exported into the prelude, but are marked with #[doc(hidden)] so they're completely invisible to users.

The benefit of this is that people can now implement traits from async_std::io for their types and stay compatible with futures. This will also simplify some trait bounds in our APIs - for example, things like where Self: futures_io::AsyncRead.

At the same time, I cleaned up some trait bounds in our stream interfaces, but haven't otherwise fiddled with them much.

I intend to follow up with another PR doing the same change for Stream so that we re-export the stream trait from futures.

@ghost ghost requested a review from yoshuawuyts September 21, 2019 12:37
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this should remove some surprising edges from async-std. This patch looks great; when CI passes I'm 👍 with merging this!

@ghost
Copy link
Author

ghost commented Sep 22, 2019

bors r+

bors bot added a commit that referenced this pull request Sep 22, 2019
224: Re-export IO traits from futures r=stjepang a=stjepang

Sorry for the big PR!

Instead of providing our own traits `async_std::io::{Read, Write, Seek, BufRead}`, we now re-export `futures::io::{AsyncRead, AsyncWrite, AsyncSeek, AsyncRead}`. While re-exporting we rename them to strip away the "Async" prefix.

The documentation will display the contents of the original traits from the `futures` crate together with our own extension methods. There's a note in the docs saying the extenion methods become available only when `async_std::prelude::*` is imported.

Our extension traits are re-exported into the prelude, but are marked with `#[doc(hidden)]` so they're completely invisible to users.

The benefit of this is that people can now implement traits from `async_std::io` for their types and stay compatible with `futures`. This will also simplify some trait bounds in our APIs - for example, things like `where Self: futures_io::AsyncRead`.

At the same time, I cleaned up some trait bounds in our stream interfaces, but haven't otherwise fiddled with them much.

I intend to follow up with another PR doing the same change for `Stream` so that we re-export the stream trait from `futures`.

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 22, 2019

Build failed

  • continuous-integration/travis-ci/push

bors bot added a commit that referenced this pull request Sep 22, 2019
224: Re-export IO traits from futures r=stjepang a=stjepang

Sorry for the big PR!

Instead of providing our own traits `async_std::io::{Read, Write, Seek, BufRead}`, we now re-export `futures::io::{AsyncRead, AsyncWrite, AsyncSeek, AsyncRead}`. While re-exporting we rename them to strip away the "Async" prefix.

The documentation will display the contents of the original traits from the `futures` crate together with our own extension methods. There's a note in the docs saying the extenion methods become available only when `async_std::prelude::*` is imported.

Our extension traits are re-exported into the prelude, but are marked with `#[doc(hidden)]` so they're completely invisible to users.

The benefit of this is that people can now implement traits from `async_std::io` for their types and stay compatible with `futures`. This will also simplify some trait bounds in our APIs - for example, things like `where Self: futures_io::AsyncRead`.

At the same time, I cleaned up some trait bounds in our stream interfaces, but haven't otherwise fiddled with them much.

I intend to follow up with another PR doing the same change for `Stream` so that we re-export the stream trait from `futures`.

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 22, 2019

Canceled

@ghost
Copy link
Author

ghost commented Sep 22, 2019

bors r+

bors bot added a commit that referenced this pull request Sep 22, 2019
224: Re-export IO traits from futures r=stjepang a=stjepang

Sorry for the big PR!

Instead of providing our own traits `async_std::io::{Read, Write, Seek, BufRead}`, we now re-export `futures::io::{AsyncRead, AsyncWrite, AsyncSeek, AsyncRead}`. While re-exporting we rename them to strip away the "Async" prefix.

The documentation will display the contents of the original traits from the `futures` crate together with our own extension methods. There's a note in the docs saying the extenion methods become available only when `async_std::prelude::*` is imported.

Our extension traits are re-exported into the prelude, but are marked with `#[doc(hidden)]` so they're completely invisible to users.

The benefit of this is that people can now implement traits from `async_std::io` for their types and stay compatible with `futures`. This will also simplify some trait bounds in our APIs - for example, things like `where Self: futures_io::AsyncRead`.

At the same time, I cleaned up some trait bounds in our stream interfaces, but haven't otherwise fiddled with them much.

I intend to follow up with another PR doing the same change for `Stream` so that we re-export the stream trait from `futures`.

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
@bors
Copy link
Contributor

bors bot commented Sep 22, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit 85b80cf into async-rs:master Sep 22, 2019
@ghost ghost deleted the reexport-traits branch September 22, 2019 14:45
@ghost ghost mentioned this pull request Sep 22, 2019
bors bot added a commit that referenced this pull request Sep 22, 2019
234: Re-export Stream from futures r=stjepang a=stjepang

This is a follow-up to #224

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant