-
Notifications
You must be signed in to change notification settings - Fork 339
Add stream timeout #348
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
Add stream timeout #348
Conversation
src/stream/stream/timeout.rs
Outdated
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] | ||
#[cfg(any(feature = "unstable", feature = "docs"))] | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq)] | ||
pub struct TimeoutError; |
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.
Should we export this too?
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.
Also, this type should not be constructible by end-users. To do prevent users from being able to create instances of TimeoutError
, do:
pub struct TimeoutError {
_private: (),
}
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.
I fixed it. b6edd12
b6edd12
to
5ef5e5b
Compare
5ef5e5b
to
10f32ca
Compare
src/stream/stream/mod.rs
Outdated
"#] | ||
#[cfg(any(feature = "unstable", feature = "docs"))] | ||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] | ||
fn timeout(self, dur: Duration) -> TimeoutStream<Self> |
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.
We don't add the "Stream" suffix to stream types so this should be just Timeout<Self>
. See other similar stream types for reference (e.g. Empty
, Repeat
, Chain
).
Co-Authored-By: Yoshua Wuyts <yoshuawuyts+github@gmail.com>
I fixed it. |
@yoshuawuyts @stjepang |
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.
This is great. Thanks so much!
close: #340
Currently, the process that times out cannot be tested.
Is there any stream processing that takes time easily?