Skip to main content

Transport

Trait Transport 

Source
pub trait Transport {
    // Required methods
    fn connect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn receive_messages(
        &mut self,
    ) -> Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, ClaudeSDKError>> + Send + '_>>;
    fn is_connected(&self) -> bool;

    // Provided method
    fn send_request<'life0, 'async_trait>(
        &'life0 mut self,
        _messages: Vec<HashMap<String, Value>>,
        _options: HashMap<String, Value>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Abstract transport for Claude communication

Required Methods§

Source

fn connect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize connection

Source

fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Close connection

Source

fn receive_messages( &mut self, ) -> Pin<Box<dyn Stream<Item = Result<HashMap<String, Value>, ClaudeSDKError>> + Send + '_>>

Receive messages from Claude

Source

fn is_connected(&self) -> bool

Check if transport is connected

Provided Methods§

Source

fn send_request<'life0, 'async_trait>( &'life0 mut self, _messages: Vec<HashMap<String, Value>>, _options: HashMap<String, Value>, ) -> Pin<Box<dyn Future<Output = Result<(), ClaudeSDKError>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Send request to Claude (not used for CLI transport - args passed via command line)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§