-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: Modify error types #69
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…and oneshot::Sender Implement mao, filter_map and filter for mpsc::Receiver oneshot::Receiver is a future, so you can just do this yourself using FutureExt.
this makes irpc::channel::mpsc::* a generic channel that can also be used for non-serializable msgs. Especially when mapping you might not want intermediate map results ot be serializable!
…erializzable msgs.
it was not exported anyway, so the resulting future was anonymous all th etime.
…an also be mapped.
In mpsc error, SenderClosed is just normal termination and should be modeled as returning None.
Frando
reviewed
Oct 8, 2025
src/lib.rs
Outdated
| }; | ||
| let fut = | ||
| async move { | ||
| let size = read.read_varint_u64().await?.ok_or(oneshot::RecvError::Io( |
Member
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.
can remove the oneshot::RecvError::Io I think because it impls From<io::Error>
Frando
approved these changes
Oct 8, 2025
Member
Frando
left a comment
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.
Looks good!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
mpsc::Receiver::recv returns a Result<Option, RecvError>. RecvError has a case
SenderClosed. So we have 2 different ways to report that the remote has closed the sender normally. Ok(None) and Err(RecvError::SenderClosed). This is confusing. SenderClosed isn't really an error, it is just what you get if the other side closes the stream.So this PR creates separate RecvError for oneshot and mpsc.
In oneshot we still need the SenderClosed case since we expect exactly 1 item, and therefore the receiver being closed before that item is an error.
In mpsc we remove the SenderClosed error and just report Ok(None) in that case.