use std::io::Write; use super::messages::IPCMessage; /// Serialize and write an IPC message to a writer (stdin pipe). pub fn send_message(writer: &mut W, msg: &IPCMessage) -> Result<(), String> { let json = serde_json::to_string(msg).map_err(|e| e.to_string())?; writer .write_all(json.as_bytes()) .map_err(|e| format!("Write error: {e}"))?; writer .write_all(b"\n") .map_err(|e| format!("Write error: {e}"))?; writer.flush().map_err(|e| format!("Flush error: {e}"))?; Ok(()) }