-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from tmtmtoo/io
Io
- Loading branch information
Showing
7 changed files
with
48 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
use crate::app::*; | ||
use crate::io::*; | ||
|
||
pub struct WaitSec { | ||
pub sec: f64, | ||
pub sleeper: std::sync::Arc<dyn Sleep + Send + Sync>, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl Component for WaitSec { | ||
type Output = (); | ||
|
||
async fn handle(&self) -> Self::Output { | ||
tokio::time::sleep(tokio::time::Duration::from_secs_f64(self.sec)).await | ||
self.sleeper.sleep_sec(self.sec).await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
pub mod tokio_impl; | ||
mod tokio_impl; | ||
|
||
pub use tokio_impl::*; | ||
|
||
#[derive(derive_new::new, Debug, Clone, PartialEq, derive_getters::Getters)] | ||
pub struct Exit { | ||
code: i32, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
pub trait PipedCmdExecutor { | ||
pub trait PipedCmdExecute { | ||
async fn piped_exec(&self, command: &str) -> std::io::Result<Exit>; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
pub trait Sleep { | ||
async fn sleep_sec(&self, sec: f64); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ extern crate derive_new; | |
|
||
mod app; | ||
mod config; | ||
mod exec; | ||
mod io; | ||
|
||
use app::*; | ||
use config::*; | ||
|