pub struct BudgetManager { /* private fields */ }Expand description
Budget manager that combines tracker and limits
Implementations§
Source§impl BudgetManager
impl BudgetManager
Sourcepub async fn set_limit(&self, limit: BudgetLimit)
pub async fn set_limit(&self, limit: BudgetLimit)
Set budget limit
Sourcepub async fn set_warning_callback(&self, callback: BudgetWarningCallback)
pub async fn set_warning_callback(&self, callback: BudgetWarningCallback)
Set warning callback
Sourcepub async fn clear_limit(&self)
pub async fn clear_limit(&self)
Clear budget limit
Sourcepub async fn get_usage(&self) -> TokenUsageTracker
pub async fn get_usage(&self) -> TokenUsageTracker
Get current usage statistics
Sourcepub async fn update_usage(
&self,
input_tokens: u64,
output_tokens: u64,
cost_usd: f64,
)
pub async fn update_usage( &self, input_tokens: u64, output_tokens: u64, cost_usd: f64, )
Update usage and check limits
Sourcepub async fn reset_usage(&self)
pub async fn reset_usage(&self)
Reset usage statistics
Sourcepub async fn is_exceeded(&self) -> bool
pub async fn is_exceeded(&self) -> bool
Check if budget is exceeded
Trait Implementations§
Source§impl Clone for BudgetManager
impl Clone for BudgetManager
Source§fn clone(&self) -> BudgetManager
fn clone(&self) -> BudgetManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BudgetManager
impl !RefUnwindSafe for BudgetManager
impl Send for BudgetManager
impl Sync for BudgetManager
impl Unpin for BudgetManager
impl !UnwindSafe for BudgetManager
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