pub struct AsyncClient { /* private fields */ }Expand description
Asynchronous client for communicating with Claude
Implementations§
Source§impl AsyncClient
impl AsyncClient
Sourcepub async fn with_defaults() -> Result<Self>
pub async fn with_defaults() -> 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 resume_session(session_uuid: Uuid) -> Result<Self>
pub async fn resume_session(session_uuid: Uuid) -> Result<Self>
Resume a previous session by UUID This creates a new client that resumes an existing session
Sourcepub async fn resume_session_with_model(
session_uuid: Uuid,
model: &str,
) -> Result<Self>
pub async fn resume_session_with_model( session_uuid: Uuid, model: &str, ) -> Result<Self>
Resume a previous session with a specific model
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: Uuid,
) -> Result<Vec<ClaudeOutput>>
pub async fn query_with_session( &mut self, text: &str, session_id: Uuid, ) -> 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: Uuid,
) -> Result<ResponseStream<'_>>
pub async fn query_stream_with_session( &mut self, text: &str, session_id: Uuid, ) -> 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)
Sourcepub fn session_uuid(&self) -> Result<Uuid>
pub fn session_uuid(&self) -> Result<Uuid>
Get the session UUID if available Returns an error if no response has been received yet