-
Notifications
You must be signed in to change notification settings - Fork 652
Merge futures-io into futures-core #1688
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
Conversation
Since that's just elision it should be backwards compatible, implementors are allowed to explicitly fill in the elided lifetimes. |
@Nemo157 |
@taiki-e this seems nice but I think we are still kinda experimenting with what the right api is within tokio-io, so maybe its right to hold off a bit once we've converted tokio and then make a decision then. |
@LucioFranco note that unlike |
(I'd personally wish this started as an issue, just so I don't feel bad about the work you've already done ;_;)
We've been thinking specifically about the required methods of Also, have My personal opinion is that the traits in |
I just migrated |
In general this seems like a good idea! The My only note here is that we've been experimenting with the signatures of the IO traits, and it seems that it would be possible to define them using pub trait AsyncRead {
async fn read(&mut self, buf: &mut [u8]) -> io::Result<usize>;
}
pub trait AsyncWrite {
async fn write(&mut self, buf: &[u8]) -> io::Result<usize>;
}
pub trait Stream {
type Item;
async fn next(&mut self) -> Option<Self::Item>;
} That's why I'd like to ask: what stability guarantees do we intend to provide? It seems that even though io traits might make it into futures-core, we would want to reserve the rights to make breaking changes to APIs as we move async/await beyond an MVP state, and will gradually unlock new capabilities that will make it possible to write more ergonomic traits. |
It is not possible to define those traits in that fashion. There is no plan for |
@cramertj my understanding was that allowing such an API may be possible, but would require overcoming challenges similar to GATs. Discussing the merits of unallocated Which brings me back to my question: does accepting this PR effectively mean we're locked into a set of APIs that cannot be changed? |
I've never heard a proposal that would work-- GATs aren't related to the issue here. The closest is my max-sized
No, it only means that the current versions of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@yoshuawuyts how about pub async trait AsyncRead {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize>;
}
pub async trait AsyncWrite {
fn write(&mut self, buf: &[u8]) -> io::Result<usize>;
}
pub async trait Stream {
type Item;
fn next(&mut self) -> Option<Self::Item>;
} (Sorry for offtop) |
@kpp I don't think that'd work; traits should be able to mix sync + async methods, which wouldn't be possible if the whole trait is marked as async. |
The discussion has stalled here and at this point I don't see much motivation to make a change like this, so closing. Feel free to reopen an issue for discussion! |
Consider flattening the crate and dropping
-preview
status #1356 (comment)https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/futures.20crate%28s%29/near/167501758
I agree that these are almost stable.
What I was thinking of as a possible change in the future was that theEDIT: See #1688 (comment)<'a>
ofAsyncBufRead
would become unnecessary by rust-lang/rust#61207 (or alternative) being merged.Another change I'm thinking about is to add
poll_{read,write}_buf
like tokio's same name methods (poll_read_buf
,poll_write_buf
). This makestokio::io::Async*
andfutures::io::Async*
almost identical, so that tokio probably can use the futures's io traits. (Stabilizing this is probably blocked by bytes 0.5 release, but sincepoll_{read,write}_buf
have default implementations, it could be made to work well by adding a feature gate. )If tokio team is interested in this... cc @carllerche @seanmonstar @LucioFranco @stjepang
r? @cramertj
cc @Nemo157 @yoshuawuyts