proc_heim/process/model/
process.rs1use std::process::ExitStatus;
2
3use tokio::process::Child;
4
5use crate::process::{
6 log_reader::LogReaderHandle, reader::MessageReaderHandle, writer::MessageWriterHandle,
7};
8
9#[derive(Debug)]
10pub(crate) struct Process {
11 pub child: Child,
12 pub message_writer: Option<MessageWriterHandle>,
13 pub message_reader: Option<MessageReaderHandle>,
14 pub log_reader: Option<LogReaderHandle>,
15}
16
17#[derive(Debug, Default)]
18pub(crate) struct ProcessBuilder {
19 pub message_writer: Option<MessageWriterHandle>,
20 pub message_reader: Option<MessageReaderHandle>,
21 pub log_reader: Option<LogReaderHandle>,
22}
23
24impl ProcessBuilder {
25 pub fn build(self, child: Child) -> Process {
26 Process {
27 child,
28 message_writer: self.message_writer,
29 message_reader: self.message_reader,
30 log_reader: self.log_reader,
31 }
32 }
33}
34
35#[derive(Debug, Clone, PartialEq, Eq)]
37pub struct ProcessInfo {
38 pid: Option<u32>,
39 exit_status: Option<ExitStatus>,
40}
41
42impl ProcessInfo {
43 pub(crate) fn new(pid: Option<u32>, exit_status: Option<ExitStatus>) -> Self {
44 Self { pid, exit_status }
45 }
46
47 pub fn pid(&self) -> Option<u32> {
49 self.pid
50 }
51
52 pub fn exit_status(&self) -> Option<ExitStatus> {
56 self.exit_status
57 }
58
59 pub fn is_running(&self) -> bool {
61 self.exit_status.is_none()
62 }
63}