hermes_runtime_components/traits/os/
child_process.rs

1use cgp::prelude::*;
2
3use crate::traits::fs::file_path::HasFilePathType;
4
5#[derive_component(ChildProcessTypeComponent, ProvideChildProcessType<Runtime>)]
6pub trait HasChildProcessType: Async {
7    type ChildProcess: Async;
8}
9
10pub type ChildProcessOf<Runtime> = <Runtime as HasChildProcessType>::ChildProcess;
11
12#[derive_component(ChildProcessStarterComponent, ChildProcessStarter<Runtime>)]
13#[async_trait]
14pub trait CanStartChildProcess: HasChildProcessType + HasFilePathType + HasErrorType {
15    async fn start_child_process(
16        &self,
17        command_path: &Self::FilePath,
18        command_args: &[&str],
19        envs: &[(&str, &str)],
20        stdout_path: Option<&Self::FilePath>,
21        stderr_path: Option<&Self::FilePath>,
22    ) -> Result<Self::ChildProcess, Self::Error>;
23}
24
25#[derive_component(ChildProcessWaiterComponent, ChildProcessWaiter<Runtime>)]
26#[async_trait]
27pub trait CanWaitChildProcess: HasChildProcessType + HasErrorType {
28    async fn wait_child_process(child_process: Self::ChildProcess) -> Result<(), Self::Error>;
29}