use std::time::{Duration, Instant};
use futures_core::Stream;
use super::{Debounce, Delay, DelayUntil, Throttle, Timeout, TimeoutAt};
pub trait StreamExt: Stream {
fn debounce(self, boundary: Duration) -> Debounce<Self>
where
Self: Sized,
{
Debounce::new(self, boundary)
}
fn delay(self, boundary: Duration) -> Delay<Self>
where
Self: Sized,
{
Delay::new(self, boundary)
}
fn delay_until(self, deadline: Instant) -> DelayUntil<Self>
where
Self: Sized,
{
DelayUntil::new(self, deadline)
}
fn throttle(self, boundary: Duration) -> Throttle<Self>
where
Self: Sized,
{
Throttle::new(self, boundary)
}
fn timeout(self, boundary: Duration) -> Timeout<Self>
where
Self: Sized,
{
Timeout::new(self, boundary)
}
fn timeout_at(self, deadline: Instant) -> TimeoutAt<Self>
where
Self: Sized,
{
TimeoutAt::new(self, deadline)
}
}
impl<S> StreamExt for S where S: Stream {}