pub struct BudgetPool { /* private fields */ }Expand description
Shared budget. Cheap to construct; record() takes a mutex.
Implementations§
Source§impl BudgetPool
impl BudgetPool
Sourcepub fn with_caps(caps: Caps) -> Self
pub fn with_caps(caps: Caps) -> Self
Build a pool with the given caps. All caps default to None.
Sourcepub fn unconstrained() -> Self
pub fn unconstrained() -> Self
Build an unconstrained pool (no caps).
Sourcepub fn record(
&self,
input_tokens: u64,
output_tokens: u64,
cost_usd: f64,
) -> Result<Totals, BudgetExceeded>
pub fn record( &self, input_tokens: u64, output_tokens: u64, cost_usd: f64, ) -> Result<Totals, BudgetExceeded>
Record one call’s usage. Returns the updated totals on success, or
BudgetExceeded (totals unchanged) on cap breach.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BudgetPool
impl RefUnwindSafe for BudgetPool
impl Send for BudgetPool
impl Sync for BudgetPool
impl Unpin for BudgetPool
impl UnsafeUnpin for BudgetPool
impl UnwindSafe for BudgetPool
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