-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbin.rs
More file actions
31 lines (26 loc) · 768 Bytes
/
bin.rs
File metadata and controls
31 lines (26 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::{Error, Result, Runner, Task};
use process_stream::Process;
use std::path::{Path, PathBuf};
use xclog::XCBuildSettings;
pub struct BinRunner {
path: PathBuf,
}
impl BinRunner {
pub fn from_build_info(info: &XCBuildSettings) -> Self {
let path = info.path_to_output_binary().unwrap_or_default();
Self { path }
}
pub fn from_path<P: AsRef<Path>>(path: P) -> Self {
let path = path.as_ref().into();
Self { path }
}
}
#[async_trait::async_trait]
impl Runner for BinRunner {
async fn run<'a>(&self, _task: &Task) -> Result<Process> {
if !self.path.exists() {
return Err(Error::Run(format!("{:?} doesn't exist!", self.path)));
}
Ok(Process::new(&self.path))
}
}