fix: Rename TimeoutStream to Timeout

yoshuawuyts-patch-1
k-nasa 5 years ago
parent 10f32ca817
commit c3f6f969c5

@ -113,7 +113,7 @@ cfg_if! {
use crate::stream::FromStream; use crate::stream::FromStream;
pub use merge::Merge; pub use merge::Merge;
pub use timeout::TimeoutStream; pub use timeout::Timeout;
} }
} }
@ -1074,11 +1074,11 @@ extension_trait! {
"#] "#]
#[cfg(any(feature = "unstable", feature = "docs"))] #[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn timeout(self, dur: Duration) -> TimeoutStream<Self> fn timeout(self, dur: Duration) -> Timeout<Self>
where where
Self: Stream + Sized, Self: Stream + Sized,
{ {
TimeoutStream::new(self, dur) Timeout::new(self, dur)
} }
#[doc = r#" #[doc = r#"

@ -11,23 +11,23 @@ use crate::task::{Context, Poll};
#[doc(hidden)] #[doc(hidden)]
#[derive(Debug)] #[derive(Debug)]
pub struct TimeoutStream<S> { pub struct Timeout<S: Stream> {
stream: S, stream: S,
delay: Delay, delay: Delay,
} }
impl<S> TimeoutStream<S> { impl<S: Stream> Timeout<S> {
pin_utils::unsafe_pinned!(stream: S); pin_utils::unsafe_pinned!(stream: S);
pin_utils::unsafe_pinned!(delay: Delay); pin_utils::unsafe_pinned!(delay: Delay);
pub fn new(stream: S, dur: Duration) -> TimeoutStream<S> { pub fn new(stream: S, dur: Duration) -> Timeout<S> {
let delay = Delay::new(dur); let delay = Delay::new(dur);
TimeoutStream { stream, delay } Timeout { stream, delay }
} }
} }
impl<S: Stream> Stream for TimeoutStream<S> { impl<S: Stream> Stream for Timeout<S> {
type Item = Result<S::Item, TimeoutError>; type Item = Result<S::Item, TimeoutError>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {

Loading…
Cancel
Save