All tests run on an 8-year-old MacBook Air.
When I built Ghost Engine — a resident Swift daemon that handles PDF rendering — I had to decide how Rust talks to it.
Two options: stdin/stdout IPC pipe, or a Unix domain socket.
I tried both. Here's what actually happened.
Option 1: stdin/stdout pipe
Simple. Spawn the process with Stdio::piped() , write commands to stdin, read responses from stdout.
let child = Command :: new ( "ghost-engine-daemon" ) .stdin ( Stdio :: piped ()) .stdout ( Stdio :: piped ()) .spawn () ? ;
// Send command writeln! ( child .stdin .as_mut () .unwrap (), "render:page:3" ) ? ;
// Read response let mut response = String :: new (); BufReader :: new ( child .stdout .as_mut () .unwrap ()) .read_line ( & mut response ) ? ;
Enter fullscreen mode
Exit fullscreen mode
Pros: Zero setup. No port conflicts. No socket file cleanup.
Cons: Strictly request-response. One command at a time per pipe pair. No multiplexing.
Option 2: Unix domain socket
More flexible.…