blob: 379c83238176f44f3363700dd3050af933127ea2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use remote_control_rs::tasks::{IntoTaskErr, Task};
pub struct Executor {
task: &'static Task,
args: Box<[String]>,
output: Option<Result<String, String>>,
}
impl Executor {
pub fn new(task: &'static Task, args: impl IntoIterator<Item = String>) -> Result<Self, IntoTaskErr> {
Ok(Self { task: task, args: args.into_iter().collect(), output: None })
}
pub fn run(&mut self) -> Option<&Result<String, String>> {
self.output = Some((self.task.exec)(&self.args));
self.output.as_ref()
}
}
|