Expand description
Process subscription for spawning and monitoring external processes.
ProcessSubscription wraps std::process::Command as a first-class
runtime Subscription. It spawns a child process, captures stdout
line-by-line, and sends messages to the model. When the subscription is
stopped (via StopSignal), termination of the immediate child is requested
and its cleanup outcome is checked.
§Migration rationale
Web Worker APIs and child-process patterns in source frameworks translate to process-based subscriptions in the terminal context. This provides a clean target for the migration code emitter.
§Example
ⓘ
use ftui_runtime::process_subscription::{ProcessSubscription, ProcessEvent};
use std::time::Duration;
#[derive(Debug)]
enum Msg {
ProcessOutput(ProcessEvent),
// ...
}
fn subscriptions() -> Vec<Box<dyn Subscription<Msg>>> {
vec![Box::new(
ProcessSubscription::new("tail", Msg::ProcessOutput)
.arg("-f")
.arg("/var/log/syslog")
.timeout(Duration::from_secs(60))
)]
}Structs§
- Process
Control - Cloneable interrupt control for exactly one
ProcessSubscriptionrun. - Process
Control Status - A snapshot of one process run, independent of model queue capacity.
- Process
Input - Bounded, cloneable input for one
ProcessSubscriptionrun. - Process
Subscription - A subscription that spawns and monitors an external process.
Enums§
- Process
Control Error - Why an interrupt could not be admitted. No child I/O occurs during admission.
- Process
Event - Events emitted by a
ProcessSubscription. - Process
Input Error - A rejected input line. The original text is returned without modification.
- Process
Interrupt Status - Result of the most recent interrupt request for one process run.
Constants§
- MAX_
PROCESS_ LINE_ BYTES - Maximum UTF-8 payload bytes in a process stdout/stderr line (64 KiB).
- PROCESS_
INPUT_ CAPACITY - Maximum queued input lines, excluding the one currently being written.