diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-07-08 23:49:00 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-07-09 00:05:22 -0400 |
commit | 27463b78a4c12c9840f9df95e4278a050b73152e (patch) | |
tree | 83e2f0b98053e53cbd82177f39ca6392903163dc /src/state.rs | |
parent | fd3f93882209b413b6bec95d3f6c806ebc01a460 (diff) | |
download | nbsh-old-27463b78a4c12c9840f9df95e4278a050b73152e.tar.gz nbsh-old-27463b78a4c12c9840f9df95e4278a050b73152e.zip |
these have no reason to be streams, they can just be futures
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/state.rs b/src/state.rs index 45ee36d..0965aea 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,5 +1,6 @@ use futures::future::Future as _; use futures::sink::Sink as _; +use futures::stream::Stream as _; use snafu::{OptionExt as _, ResultExt as _}; use std::io::Write as _; @@ -93,29 +94,28 @@ impl State { } } -impl futures::stream::Stream for State { +impl futures::future::Future for State { type Item = (); type Error = Error; - fn poll(&mut self) -> futures::Poll<Option<Self::Item>, Self::Error> { - let event = futures::try_ready!(self - .r - .poll() - .map_err(|_| Error::Unreachable)); - match event { - Some(StateEvent::Start(idx, cmd, args)) => { - self.command_start(idx, &cmd, &args)?; - Ok(futures::Async::Ready(Some(()))) + fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> { + loop { + let event = futures::try_ready!(self + .r + .poll() + .map_err(|_| Error::Unreachable)); + match event { + Some(StateEvent::Start(idx, cmd, args)) => { + self.command_start(idx, &cmd, &args)?; + } + Some(StateEvent::Output(idx, output)) => { + self.command_output(idx, &output)?; + } + Some(StateEvent::Exit(idx, status)) => { + self.command_exit(idx, status)?; + } + None => return Ok(futures::Async::Ready(())), } - Some(StateEvent::Output(idx, output)) => { - self.command_output(idx, &output)?; - Ok(futures::Async::Ready(Some(()))) - } - Some(StateEvent::Exit(idx, status)) => { - self.command_exit(idx, status)?; - Ok(futures::Async::Ready(Some(()))) - } - None => Ok(futures::Async::Ready(None)), } } } |