use std::fmt;
use std::path::{Path, PathBuf};
use crate::AppCommand;
use crate::durability::LauncherTie;
use crate::pal::error::PalError;
use crate::pal::ids::{AppId, JobId, PtyId};
use crate::pal::processes::ResolvedCommand;
use crate::session_record::ProcessIdentity;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub(crate) enum ProcessLiveness {
Live,
Dead,
InspectFailed,
}
#[derive(Clone, Debug)]
pub(crate) struct SupervisorSpawn {
pub exe: PathBuf,
pub args: Vec<String>,
}
#[derive(Clone, Debug)]
pub(crate) struct AppSpawn {
pub command: AppCommand,
pub launch_directory: PathBuf,
pub pty: PtyId,
pub job: JobId,
}
#[cfg_attr(test, mockall::automock)]
pub(crate) trait Processes: Send + Sync + fmt::Debug + 'static {
fn current_exe(&self) -> Result<PathBuf, PalError>;
fn spawn_supervisor(&self, request: &SupervisorSpawn) -> Result<ProcessIdentity, PalError>;
fn launcher_tie(&self) -> LauncherTie;
fn probe(&self, identity: &ProcessIdentity) -> ProcessLiveness;
fn terminate(&self, identity: &ProcessIdentity) -> Result<(), PalError>;
fn create_lifetime_job(&self) -> Result<JobId, PalError>;
fn close_job(&self, job: JobId);
fn spawn_app(&self, request: &AppSpawn) -> Result<AppId, PalError>;
fn wait_app(&self, app: AppId) -> Result<i32, PalError>;
fn current_identity(&self) -> Result<ProcessIdentity, PalError>;
fn random_nonce(&self) -> String;
fn resolve_executable(&self, command: &str, launch_directory: &Path) -> ResolvedCommand;
}