procwire_client/control/mod.rs
1//! Control plane module - `$init` message and stdio I/O.
2//!
3//! The control plane uses JSON over stdio for the initial handshake.
4//! After handshake, all communication happens on the data plane (pipe).
5//!
6//! # Workflow
7//!
8//! 1. Child creates pipe listener
9//! 2. Child sends `$init` via stdout (JSON-RPC)
10//! 3. Parent validates schema
11//! 4. Parent connects to pipe
12//! 5. Binary communication begins on data plane
13//!
14//! # Example
15//!
16//! ```ignore
17//! use procwire_client::control::{build_init_message, write_stdout_line, InitSchema, ResponseType};
18//! use procwire_client::transport::generate_pipe_path;
19//!
20//! // Create schema
21//! let mut schema = InitSchema::new();
22//! schema.add_method("echo", 1, ResponseType::Result);
23//!
24//! // Send $init
25//! let pipe_path = generate_pipe_path();
26//! let init_msg = build_init_message(&pipe_path, &schema);
27//! write_stdout_line(&init_msg)?;
28//! ```
29
30mod init;
31mod stdio;
32
33// New API
34pub use init::{
35 build_init_message, EventSchema, InitSchema, MethodSchema, ResponseType, PROTOCOL_VERSION,
36};
37pub use stdio::{write_stdout_json, write_stdout_line};
38
39// Legacy API (for backward compatibility)
40pub use init::{EventDef, InitMessage, InitParams, MethodDef, Schema};