pub struct AsyncClient { /* private fields */ }Expand description
Asynchronous client for communicating with Claude
Implementations§
Source§impl AsyncClient
impl AsyncClient
Sourcepub async fn default() -> Result<Self>
pub async fn default() -> Result<Self>
Create a client with default settings (using logic from start_claude)
Sourcepub async fn with_model(model: &str) -> Result<Self>
pub async fn with_model(model: &str) -> Result<Self>
Create a client with a specific model
Sourcepub async fn from_builder(builder: ClaudeCliBuilder) -> Result<Self>
pub async fn from_builder(builder: ClaudeCliBuilder) -> Result<Self>
Create a client from a custom builder
Sourcepub async fn query(&mut self, text: &str) -> Result<Vec<ClaudeOutput>>
pub async fn query(&mut self, text: &str) -> Result<Vec<ClaudeOutput>>
Send a query and collect all responses until Result message This is the simplified version that collects all responses
Sourcepub async fn query_with_session(
&mut self,
text: &str,
session_id: &str,
) -> Result<Vec<ClaudeOutput>>
pub async fn query_with_session( &mut self, text: &str, session_id: &str, ) -> Result<Vec<ClaudeOutput>>
Send a query with a custom session ID and collect all responses
Sourcepub async fn query_stream(&mut self, text: &str) -> Result<ResponseStream<'_>>
pub async fn query_stream(&mut self, text: &str) -> Result<ResponseStream<'_>>
Send a query and return an async iterator over responses Returns a stream that yields ClaudeOutput until Result message is received
Sourcepub async fn query_stream_with_session(
&mut self,
text: &str,
session_id: &str,
) -> Result<ResponseStream<'_>>
pub async fn query_stream_with_session( &mut self, text: &str, session_id: &str, ) -> Result<ResponseStream<'_>>
Send a query with session ID and return an async iterator over responses
Sourcepub async fn send(&mut self, input: &ClaudeInput) -> Result<()>
pub async fn send(&mut self, input: &ClaudeInput) -> Result<()>
Send a ClaudeInput directly
Sourcepub async fn receive(&mut self) -> Result<ClaudeOutput>
pub async fn receive(&mut self) -> Result<ClaudeOutput>
Try to receive a single response
Sourcepub fn take_stderr(&mut self) -> Option<BufReader<ChildStderr>>
pub fn take_stderr(&mut self) -> Option<BufReader<ChildStderr>>
Take the stderr reader (can only be called once)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncClient
impl !RefUnwindSafe for AsyncClient
impl Send for AsyncClient
impl Sync for AsyncClient
impl Unpin for AsyncClient
impl !UnwindSafe for AsyncClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more