Skip to main content

run_formatter

Function run_formatter 

Source
pub fn run_formatter(body: &str, argv: &[String]) -> Result<String, String>
Expand description

Pipe body through the formatter argv via stdin/stdout. Returns the formatter’s stdout on success. Returns Err(message) on any failure mode (binary missing, non-zero exit, timeout, I/O); the caller is expected to log the message and fall back to the input.

The wait is implemented with a watchdog thread that calls Child::kill after FORMATTER_TIMEOUT_SECS. On the happy path the watchdog is signalled to exit via an mpsc channel and joins immediately.