Skip to main content

ssh_mcp/background/
mod.rs

1//! Local background job state and log spooling.
2//!
3//! The core types are:
4//! - [`JobState`]: per-job state (pid, local log path, exit code, status)
5//! - [`JobRegistry`]: thread-safe registry for active + recently completed jobs
6//! - [`LocalLogSpooler`]: configured or per-user local spool directory management
7
8pub mod job;
9pub(crate) mod marker;
10pub mod registry;
11pub(crate) mod response;
12pub mod spooler;
13pub mod stream;
14pub(crate) mod wrapper;
15
16pub use job::{JobState, JobStatus, SharedJobState};
17pub use registry::JobRegistry;
18pub use spooler::LocalLogSpooler;
19pub use stream::OutputStreamer;
20
21use thiserror::Error;
22
23/// Background subsystem errors.
24#[derive(Debug, Error)]
25pub enum BackgroundError {
26    #[error("io error: {0}")]
27    Io(#[from] std::io::Error),
28
29    #[error("invalid job id: {job_id}")]
30    InvalidJobId { job_id: String },
31
32    #[error("job not found: {job_id}")]
33    JobNotFound { job_id: String },
34
35    #[error("invalid job state: {message}")]
36    InvalidState { message: &'static str },
37
38    #[error("time error: {0}")]
39    Time(#[from] std::time::SystemTimeError),
40}
41
42pub type Result<T> = std::result::Result<T, BackgroundError>;