Exit signal gets its own trait (#433)

* Exit signal gets its own trait

* Typo

* Removed clone bounds
This commit is contained in:
Arkadiy Paronyan
2018-07-28 08:31:16 +02:00
committed by GitHub
parent 97a6db785e
commit 31db321814
4 changed files with 39 additions and 30 deletions
+8 -6
View File
@@ -38,11 +38,9 @@ mod vergen {
// the regular polkadot worker simply does nothing until ctrl-c
struct Worker;
impl cli::Worker for Worker {
type Work = Self::Exit;
impl cli::IntoExit for Worker {
type Exit = future::MapErr<oneshot::Receiver<()>, fn(oneshot::Canceled) -> ()>;
fn exit_only(&self) -> Self::Exit {
fn into_exit(self) -> Self::Exit {
// can't use signal directly here because CtrlC takes only `Fn`.
let (exit_send, exit) = oneshot::channel();
@@ -55,9 +53,13 @@ impl cli::Worker for Worker {
exit.map_err(drop)
}
}
fn work<C: ServiceComponents>(self, _service: &Service<C>) -> Self::Exit {
self.exit_only()
impl cli::Worker for Worker {
type Work = <Self as cli::IntoExit>::Exit;
fn work<C: ServiceComponents>(self, _service: &Service<C>) -> Self::Work {
use cli::IntoExit;
self.into_exit()
}
}