SubprocessTransport

Struct SubprocessTransport 

Source
pub struct SubprocessTransport { /* private fields */ }
Expand description

Subprocess-based transport for Claude CLI

Implementations§

Source§

impl SubprocessTransport

Source

pub fn new(options: ClaudeCodeOptions) -> Result<Self>

Create a new subprocess transport

Source

pub fn subscribe_messages( &self, ) -> Option<Pin<Box<dyn Stream<Item = Result<Message>> + Send + 'static>>>

Subscribe to messages without borrowing self (for lock-free consumption)

Source

pub async fn receive_sdk_control_request(&mut self) -> Option<Value>

Receive SDK control requests

Source

pub fn take_sdk_control_receiver(&mut self) -> Option<Receiver<Value>>

Take the SDK control receiver (can only be called once)

Source

pub fn with_cli_path( options: ClaudeCodeOptions, cli_path: impl Into<PathBuf>, ) -> Self

Create with a specific CLI path

Source

pub fn set_close_stdin_after_prompt(&mut self, close: bool)

Set whether to close stdin after sending the initial prompt

Source

pub fn for_print_mode( options: ClaudeCodeOptions, _prompt: String, ) -> Result<Self>

Create transport for simple print mode (one-shot query)

Trait Implementations§

Source§

impl Drop for SubprocessTransport

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Transport for SubprocessTransport

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Get self as Any for downcasting
Source§

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

Connect to the Claude CLI
Source§

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

Send a message to Claude
Source§

fn receive_messages( &mut self, ) -> Pin<Box<dyn Stream<Item = Result<Message>> + Send + 'static>>

Receive messages from Claude as a stream
Source§

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

Send a control request (e.g., interrupt)
Source§

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

Receive control responses
Source§

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

Send an SDK control request (for control protocol)
Source§

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

Send an SDK control response
Source§

fn is_connected(&self) -> bool

Check if the transport is connected
Source§

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

Disconnect from the Claude CLI
Source§

fn take_sdk_control_receiver(&mut self) -> Option<Receiver<Value>>

Take the SDK control receiver, if supported by the transport Default implementation returns None for transports that do not support inbound control messages.
Source§

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

Signal end of input stream (default: no-op)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more