proc_heim/process/model/runnable.rs
1use std::{fmt::Debug, path::Path};
2
3use super::Cmd;
4
5/// Trait, which enables using of user-defined types for creating a custom process.
6pub trait Runnable: Debug + Send + 'static {
7 /// This method should prepare process to run and return [`Cmd`](struct@crate::model::command::Cmd) used to spawn a custom process.
8 /// If you need to create some files for properly spawning a process, do it inside provided `process_dir` directory.
9 fn bootstrap_cmd(&self, process_dir: &Path) -> Result<Cmd, String>;
10 /// This method is called when process spawning fails.
11 /// Notice that `process_dir` will be deleted automatically, so there is no need to delete it here.
12 #[allow(unused_variables)]
13 fn clean_after_fail(&self, process_dir: &Path) -> Result<(), String> {
14 Ok(())
15 }
16}