summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2021-10-26 23:57:33 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2021-10-26 23:57:33 +0200
commitddb92b57fb92a43dcd3ac03ba987636bbc5d1843 (patch)
tree8aa9c765e56a330239671dae4a664dc909a69c78
parentb24d2670bd5bbd70dabddc489e96cf0ba1f9e8ba (diff)
downloadrebel-ddb92b57fb92a43dcd3ac03ba987636bbc5d1843.tar
rebel-ddb92b57fb92a43dcd3ac03ba987636bbc5d1843.zip
runner: move Checkable trait into separabe module
-rw-r--r--crates/runner/src/lib.rs7
-rw-r--r--crates/runner/src/tar.rs2
-rw-r--r--crates/runner/src/task.rs2
-rw-r--r--crates/runner/src/util/checkable.rs37
-rw-r--r--crates/runner/src/util/mod.rs39
5 files changed, 42 insertions, 45 deletions
diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs
index 81e328e..d0cc531 100644
--- a/crates/runner/src/lib.rs
+++ b/crates/runner/src/lib.rs
@@ -25,12 +25,9 @@ use nix::{
use uds::UnixSeqpacketConn;
use common::{error::*, types::*};
-use util::Checkable;
-use self::{
- jobserver::Jobserver,
- util::{clone, unix},
-};
+use jobserver::Jobserver;
+use util::{checkable::Checkable, clone, unix};
#[derive(Debug, Clone)]
pub struct Options {
diff --git a/crates/runner/src/tar.rs b/crates/runner/src/tar.rs
index 9306775..1fc4bbb 100644
--- a/crates/runner/src/tar.rs
+++ b/crates/runner/src/tar.rs
@@ -16,7 +16,7 @@ use common::error::*;
use super::{
ns,
- util::{fs, Checkable},
+ util::{checkable::Checkable, fs},
};
use crate::paths;
diff --git a/crates/runner/src/task.rs b/crates/runner/src/task.rs
index e27fd49..2b0070b 100644
--- a/crates/runner/src/task.rs
+++ b/crates/runner/src/task.rs
@@ -22,7 +22,7 @@ use common::{error::*, string_hash::*, types::*};
use super::{
jobserver::Jobserver,
ns, tar,
- util::{cjson, fs, Checkable},
+ util::{checkable::Checkable, cjson, fs},
};
use crate::{paths, util::unix};
diff --git a/crates/runner/src/util/checkable.rs b/crates/runner/src/util/checkable.rs
new file mode 100644
index 0000000..8528d29
--- /dev/null
+++ b/crates/runner/src/util/checkable.rs
@@ -0,0 +1,37 @@
+use std::{
+ io::{Error, ErrorKind, Result},
+ process::ExitStatus,
+};
+
+use nix::sys::wait;
+
+pub trait Checkable {
+ fn check(&self) -> Result<()>;
+}
+
+impl Checkable for ExitStatus {
+ fn check(&self) -> Result<()> {
+ if self.success() {
+ Ok(())
+ } else {
+ Err(Error::new(
+ ErrorKind::Other,
+ format!("Process exited with {}", self),
+ ))
+ }
+ }
+}
+
+impl Checkable for wait::WaitStatus {
+ fn check(&self) -> Result<()> {
+ let message = match self {
+ wait::WaitStatus::Exited(_, 0) => return Ok(()),
+ wait::WaitStatus::Exited(_, code) => format!("Process exited with exit code: {}", code),
+ wait::WaitStatus::Signaled(_, signal, _) => {
+ format!("Process exited with signal: {}", signal)
+ }
+ _ => format!("Process in unexpected status: {:?}", self),
+ };
+ Err(Error::new(ErrorKind::Other, message))
+ }
+}
diff --git a/crates/runner/src/util/mod.rs b/crates/runner/src/util/mod.rs
index eff589d..5310ccf 100644
--- a/crates/runner/src/util/mod.rs
+++ b/crates/runner/src/util/mod.rs
@@ -1,42 +1,5 @@
+pub mod checkable;
pub mod cjson;
pub mod clone;
pub mod fs;
pub mod unix;
-
-use std::{
- io::{Error, ErrorKind, Result},
- process::ExitStatus,
-};
-
-use nix::sys::wait;
-
-pub trait Checkable {
- fn check(&self) -> Result<()>;
-}
-
-impl Checkable for ExitStatus {
- fn check(&self) -> Result<()> {
- if self.success() {
- Ok(())
- } else {
- Err(Error::new(
- ErrorKind::Other,
- format!("Process exited with {}", self),
- ))
- }
- }
-}
-
-impl Checkable for wait::WaitStatus {
- fn check(&self) -> Result<()> {
- let message = match self {
- wait::WaitStatus::Exited(_, 0) => return Ok(()),
- wait::WaitStatus::Exited(_, code) => format!("Process exited with exit code: {}", code),
- wait::WaitStatus::Signaled(_, signal, _) => {
- format!("Process exited with signal: {}", signal)
- }
- _ => format!("Process in unexpected status: {:?}", self),
- };
- Err(Error::new(ErrorKind::Other, message))
- }
-}