pub struct StdioTransport { /* private fields */ }Expand description
Stdio transport for JSON-RPC communication
Supports two modes:
- Native mode: Uses process stdin/stdout directly
- Child mode: Communicates with a spawned child process
Implementations§
Source§impl StdioTransport
impl StdioTransport
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new stdio transport using stdin/stdout
This is used for server-side communication where the process reads from stdin and writes to stdout.
Sourcepub fn with_config(config: TransportConfig) -> Self
pub fn with_config(config: TransportConfig) -> Self
Create a new stdio transport with custom configuration
Sourcepub fn from_streams<R, W>(reader: R, writer: W, config: TransportConfig) -> Self
pub fn from_streams<R, W>(reader: R, writer: W, config: TransportConfig) -> Self
Create a stdio transport from async read/write streams
Wraps the reader in a BufReader for efficient reading.
Sourcepub async fn spawn_child(command: &mut Command) -> Result<Self>
pub async fn spawn_child(command: &mut Command) -> Result<Self>
Spawn a child process and create a transport to communicate with it
The child process should implement the JSON-RPC protocol over stdio.
Sourcepub async fn spawn_child_with_config(
command: &mut Command,
config: TransportConfig,
) -> Result<Self>
pub async fn spawn_child_with_config( command: &mut Command, config: TransportConfig, ) -> Result<Self>
Spawn a child process with custom configuration
Sourcepub fn with_tokio_stdio() -> Self
pub fn with_tokio_stdio() -> Self
Initialize with tokio stdin/stdout
Must be called within a tokio runtime context.
Sourcepub fn child(&mut self) -> Option<&mut Child>
pub fn child(&mut self) -> Option<&mut Child>
Get the child process if this transport was created via spawn_child
Sourcepub fn is_child_running(&mut self) -> bool
pub fn is_child_running(&mut self) -> bool
Check if there’s a child process and if it’s still running
Sourcepub async fn wait_child(&mut self) -> Result<Option<ExitStatus>>
pub async fn wait_child(&mut self) -> Result<Option<ExitStatus>>
Wait for the child process to exit and return its status