1mod command;
37mod error;
38mod output;
39mod child;
40
41pub use command::{Command, CommandBuilder, shell, exec, which};
42pub use error::ProcessError;
43pub use output::ProcessOutput;
44pub use child::{Child, ExitStatus};
45
46use async_trait::async_trait;
47use unistore_core::{Capability, CapabilityError, CapabilityInfo};
48
49pub struct ProcessCapability {
51 started: std::sync::atomic::AtomicBool,
52}
53
54impl ProcessCapability {
55 pub fn new() -> Self {
57 Self {
58 started: std::sync::atomic::AtomicBool::new(false),
59 }
60 }
61}
62
63impl Default for ProcessCapability {
64 fn default() -> Self {
65 Self::new()
66 }
67}
68
69#[async_trait]
70impl Capability for ProcessCapability {
71 fn info(&self) -> CapabilityInfo {
72 CapabilityInfo::new("process", "0.1.0")
73 .with_description("Process management capability")
74 }
75
76 async fn start(&mut self) -> Result<(), CapabilityError> {
77 self.started
78 .store(true, std::sync::atomic::Ordering::SeqCst);
79 tracing::info!("Process capability started");
80 Ok(())
81 }
82
83 async fn stop(&mut self) -> Result<(), CapabilityError> {
84 self.started
85 .store(false, std::sync::atomic::Ordering::SeqCst);
86 tracing::info!("Process capability stopped");
87 Ok(())
88 }
89
90 async fn health_check(&self) -> Result<(), CapabilityError> {
91 if self.started.load(std::sync::atomic::Ordering::SeqCst) {
92 Ok(())
93 } else {
94 Err(CapabilityError::unhealthy("process", "capability not started"))
95 }
96 }
97}