cargo fmt

This commit is contained in:
Jeremy Wall 2021-12-30 18:57:55 -05:00
parent eb1d17407e
commit 3b9daf442a
3 changed files with 22 additions and 16 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
use notify::DebouncedEvent;
#[derive(PartialEq,Clone)]
#[derive(PartialEq, Clone)]
pub enum WatchEventType {
Touched,
Changed,

View File

@ -16,9 +16,8 @@ use std::time::Duration;
use std::process::{Command, Stdio};
use traits::Process;
use error::CommandError;
use traits::Process;
fn env_var_to_tuple(var: &str) -> (String, String) {
let mut vs = var.split('=');
@ -26,13 +25,16 @@ fn env_var_to_tuple(var: &str) -> (String, String) {
return match vs.next() {
Some(val) => (String::from(name), String::from(val)),
None => (String::from(name), "".to_string()),
}
};
}
("".to_string(), "".to_string())
}
pub fn run_cmd(cmd: &str, env: &Option<Vec<&str>>) -> Result<i32, CommandError> {
let args = cmd.split(' ').filter(|s| !s.is_empty()).collect::<Vec<&str>>();
let args = cmd
.split(' ')
.filter(|s| !s.is_empty())
.collect::<Vec<&str>>();
if args.len() < 1 {
return Err(CommandError::new("Empty command string passed in"));
}
@ -55,7 +57,7 @@ pub fn run_cmd(cmd: &str, env: &Option<Vec<&str>>) -> Result<i32, CommandError>
},
// TODO(jeremy): We should not swallow this error.
Err(_) => Err(CommandError::new("Error running command")),
}
};
}
fn is_cmd_success(cmd: &str, env: Option<Vec<&str>>) -> bool {
@ -74,11 +76,13 @@ pub struct ExecProcess<'a> {
}
impl<'a> ExecProcess<'a> {
pub fn new(test_cmd: &'a str,
pub fn new(
test_cmd: &'a str,
cmd: &'a str,
negate: bool,
env: Option<Vec<&'a str>>,
poll: Duration) -> ExecProcess<'a> {
poll: Duration,
) -> ExecProcess<'a> {
ExecProcess {
test_cmd: test_cmd,
negate: negate,

View File

@ -14,9 +14,9 @@
use std::thread;
use std::time::Duration;
use traits::Process;
use error::CommandError;
use exec::run_cmd;
use traits::Process;
pub struct TimerProcess<'a> {
cmd: &'a str,
@ -26,10 +26,12 @@ pub struct TimerProcess<'a> {
}
impl<'a> TimerProcess<'a> {
pub fn new(cmd: &'a str,
pub fn new(
cmd: &'a str,
env: Option<Vec<&'a str>>,
poll_duration: Duration,
max_repeat: Option<u32>) -> TimerProcess<'a> {
max_repeat: Option<u32>,
) -> TimerProcess<'a> {
TimerProcess {
cmd: cmd,
env: env,