pub struct OptimizedClient { /* private fields */ }Expand description
Optimized client with improved performance characteristics
Implementations§
Source§impl OptimizedClient
impl OptimizedClient
Sourcepub fn new(options: ClaudeCodeOptions, mode: ClientMode) -> Result<Self>
pub fn new(options: ClaudeCodeOptions, mode: ClientMode) -> Result<Self>
Create a new optimized client
Sourcepub async fn query(&self, prompt: String) -> Result<Vec<Message>>
pub async fn query(&self, prompt: String) -> Result<Vec<Message>>
Execute a one-shot query with automatic retry
Sourcepub async fn query_with_retry(
&self,
prompt: String,
max_retries: u32,
initial_delay: Duration,
) -> Result<Vec<Message>>
pub async fn query_with_retry( &self, prompt: String, max_retries: u32, initial_delay: Duration, ) -> Result<Vec<Message>>
Execute a query with custom retry configuration
Sourcepub async fn get_usage_stats(&self) -> TokenUsageTracker
pub async fn get_usage_stats(&self) -> TokenUsageTracker
Get token/cost usage statistics
Sourcepub async fn set_budget_limit(
&self,
limit: BudgetLimit,
on_warning: Option<BudgetWarningCallback>,
)
pub async fn set_budget_limit( &self, limit: BudgetLimit, on_warning: Option<BudgetWarningCallback>, )
Set budget limit with optional warning callback
Example:
use cc_sdk::{OptimizedClient, ClaudeCodeOptions, ClientMode};
use cc_sdk::token_tracker::{BudgetLimit, BudgetWarningCallback};
use std::sync::Arc;
let client = OptimizedClient::new(ClaudeCodeOptions::default(), ClientMode::OneShot)?;
let cb: BudgetWarningCallback = Arc::new(|msg: &str| println!("Warn: {}", msg));
client.set_budget_limit(BudgetLimit::with_cost(1.0), Some(cb)).await;Sourcepub async fn clear_budget_limit(&self)
pub async fn clear_budget_limit(&self)
Clear budget limit and reset warning state
Sourcepub async fn reset_usage_stats(&self)
pub async fn reset_usage_stats(&self)
Reset usage statistics to zero
Sourcepub async fn is_budget_exceeded(&self) -> bool
pub async fn is_budget_exceeded(&self) -> bool
Check whether budget is exceeded
Sourcepub async fn start_interactive_session(&self) -> Result<()>
pub async fn start_interactive_session(&self) -> Result<()>
Start an interactive session
Sourcepub async fn send_interactive(&self, prompt: String) -> Result<()>
pub async fn send_interactive(&self, prompt: String) -> Result<()>
Send a message in interactive mode
Sourcepub async fn receive_interactive(&self) -> Result<Vec<Message>>
pub async fn receive_interactive(&self) -> Result<Vec<Message>>
Receive messages in interactive mode
Sourcepub async fn process_batch(
&self,
prompts: Vec<String>,
) -> Result<Vec<Result<Vec<Message>>>>
pub async fn process_batch( &self, prompts: Vec<String>, ) -> Result<Vec<Result<Vec<Message>>>>
Process a batch of queries concurrently
Sourcepub async fn end_interactive_session(&self) -> Result<()>
pub async fn end_interactive_session(&self) -> Result<()>
End interactive session
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OptimizedClient
impl !RefUnwindSafe for OptimizedClient
impl Send for OptimizedClient
impl Sync for OptimizedClient
impl Unpin for OptimizedClient
impl !UnwindSafe for OptimizedClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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