pub struct BudgetLimit {
pub max_cost_usd: Option<f64>,
pub max_tokens: Option<u64>,
pub warning_threshold: f64,
}Expand description
Budget limits and alerts
Fields§
§max_cost_usd: Option<f64>Maximum cost in USD (None = unlimited)
max_tokens: Option<u64>Maximum total tokens (None = unlimited)
warning_threshold: f64Threshold percentage for warning (0.0-1.0, default 0.8 for 80%)
Implementations§
Source§impl BudgetLimit
impl BudgetLimit
Sourcepub fn with_tokens(max_tokens: u64) -> Self
pub fn with_tokens(max_tokens: u64) -> Self
Create a new budget limit with token cap
Sourcepub fn with_both(max_cost_usd: f64, max_tokens: u64) -> Self
pub fn with_both(max_cost_usd: f64, max_tokens: u64) -> Self
Create a new budget limit with both caps
Sourcepub fn with_warning_threshold(self, threshold: f64) -> Self
pub fn with_warning_threshold(self, threshold: f64) -> Self
Set warning threshold (0.0-1.0)
Sourcepub fn check_limits(&self, usage: &TokenUsageTracker) -> BudgetStatus
pub fn check_limits(&self, usage: &TokenUsageTracker) -> BudgetStatus
Check if usage exceeds limits
Trait Implementations§
Source§impl Clone for BudgetLimit
impl Clone for BudgetLimit
Source§fn clone(&self) -> BudgetLimit
fn clone(&self) -> BudgetLimit
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 moreSource§impl Debug for BudgetLimit
impl Debug for BudgetLimit
Auto Trait Implementations§
impl Freeze for BudgetLimit
impl RefUnwindSafe for BudgetLimit
impl Send for BudgetLimit
impl Sync for BudgetLimit
impl Unpin for BudgetLimit
impl UnwindSafe for BudgetLimit
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