claude_code_sdk/transport/
mod.rs

1//! Transport implementations for Claude SDK.
2
3use futures::Stream;
4use std::collections::HashMap;
5use std::pin::Pin;
6use crate::errors::ClaudeSDKError;
7
8pub mod subprocess_cli;
9
10/// Abstract transport for Claude communication
11#[async_trait::async_trait]
12pub trait Transport {
13    /// Initialize connection
14    async fn connect(&mut self) -> Result<(), ClaudeSDKError>;
15    
16    /// Close connection
17    async fn disconnect(&mut self) -> Result<(), ClaudeSDKError>;
18    
19    /// Send request to Claude (not used for CLI transport - args passed via command line)
20    #[allow(dead_code)]
21    async fn send_request(
22        &mut self,
23        _messages: Vec<HashMap<String, serde_json::Value>>,
24        _options: HashMap<String, serde_json::Value>,
25    ) -> Result<(), ClaudeSDKError> {
26        Ok(())
27    }
28    
29    /// Receive messages from Claude
30    fn receive_messages(&mut self) -> Pin<Box<dyn Stream<Item = Result<HashMap<String, serde_json::Value>, ClaudeSDKError>> + Send + '_>>;
31    
32    /// Check if transport is connected
33    #[allow(dead_code)]
34    fn is_connected(&self) -> bool;
35}