-
Notifications
You must be signed in to change notification settings - Fork 653
Consider an alternate naming scheme for Sink
fns
#751
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
Comments
Agreed -- I think this was a case of crossed wires, when we were considering moving away from the cc @cramertj |
I avoided getting into it, however I think that This is what I think pub trait Sink {
type Item;
type Error;
fn poll_ready(&mut self) -> Poll<(), Self::Error>;
fn start_send(&mut self, item: Self::Item) -> Result<(), Self::Error>;
fn start_close(&mut self) -> Result<(), Self::Error>;
fn poll_flush(&mut self) -> Poll<(), Self::Error>;
} IMO the current Also, in this proposal, the close strategy is transitioned to a fn This proposal is based on how my implementations of |
Oh, and the proposal has no opinion on the naming of |
@carllerche This looks great! I remember back when we were first doing One question: what guarantees do we expect for |
Something like
What is permitted is |
@cramertj @alexcrichton thoughts on this proposal? To me it seems to clean up (Granted there's still the borrowing issues @cramertj, but that's why it's a separate crate we can iterate on...) |
Seems fine by me! |
+1 from me. |
@carllerche I encountered an interesting case when transitioning some of the |
Yes, the solution to these cases is to either add a single buffer slot or not implement |
@carllerche After implementing this change, I found that many implementations needed to store Edit: alternatively, a |
IMO it comes down to defining what each fn means specifically around what happens when you call In my impls, I have been treating it as an error (as the sink is closed) and the Also, Basically, it comes down to whether or not you make the lifecycle of a |
@carllerche That makes sense. I think my personal preference would be to make the behavior of |
Closing, this is done. |
#747 recently renamed
poll_complete
->flush
, dropping thepoll_
prefix.I would suggest to do the opposite. Keep
poll_flush
and renameclose
->poll_close
.The primary reason is to reserve
flush
andclose
for futures that perform these operations, especially for async / await. This would allow:and
I have other thoughts on
Sink
based on experience implementing and using it, but I am assuming that there will be an RFC at some point to go into more depth on theSink
API.The text was updated successfully, but these errors were encountered: