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

Stream: finish after returning the first error #2773

Open
SZenglein opened this issue Sep 18, 2023 · 1 comment
Open

Stream: finish after returning the first error #2773

SZenglein opened this issue Sep 18, 2023 · 1 comment
Labels
A-stream Area: futures::stream C-feature-request

Comments

@SZenglein
Copy link

A wrapper type for streams that functions almost like take_while but also returns the first value that matches the condition would be nice to have.

My use-case is returning a (grpc) stream that should terminate as soon as one error occurs. However, it is very inconvenient to also return the specific error reason to indicate the stream has not completed normally, but with an error.

@taiki-e taiki-e added C-feature-request A-stream Area: futures::stream labels Oct 25, 2023
@akauppi
Copy link

akauppi commented Mar 15, 2024

I would also be in need of "failing" a stream, from within (at its .poll_next).

There are two ways of doing this:

  • the "wrapper" that you suggest. A Stream would produce Result and in the consuming chain, that is detected as an error
  • remake the Stream implementation so that .poll_next can signal error (currently, it cannot, and this is likely intentional; Result return types are used for this)

I'm familiar with Akka Streams, before coming to Rust, and there a failure in the producer fails the whole stream. That's pretty practical, often, and something we could have - I'll do some experimenting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stream Area: futures::stream C-feature-request
Projects
None yet
Development

No branches or pull requests

3 participants