tokio-timer
tokio-timer copied to clipboard
Consider generalizing TimeoutStream / adding an IdleStream adapter
In my project I need to execute some action if a stream has not responded for some amount of time and then continue with normal operation of the stream; essentially, an idle callback.
I copied TimeoutStream
into my project and modified a few lines. Instead of raising on error on timeout I invoke a closure and resume polling the stream.
// [...]
Ok(Async::Ready(_)) => {
// Timeout has elapsed, reest and continue
self.sleep = self.timer.sleep(self.duration);
(self.on_idle)();
self.poll()
}
// [...]
Would this IdleStream
be a good fit for inclusion in this crate ?