pub struct UsageTracker {
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_read_tokens: u64,
pub cache_write_tokens: u64,
pub total_cost_usd: f64,
/* private fields */
}Expand description
Accumulates token usage and USD cost for the current session.
Fields§
§input_tokens: u64§output_tokens: u64§cache_read_tokens: u64§cache_write_tokens: u64§total_cost_usd: f64Implementations§
Source§impl UsageTracker
impl UsageTracker
pub fn new(budget_usd: Option<f64>) -> Self
Sourcepub fn record(
&mut self,
input: u64,
output: u64,
cache_read: u64,
cache_write: u64,
cost_usd: f64,
) -> BudgetStatus
pub fn record( &mut self, input: u64, output: u64, cache_read: u64, cache_write: u64, cost_usd: f64, ) -> BudgetStatus
Record a single LLM call. cost_usd should be pre-computed by the
caller using ModelRegistry::estimate_cost.
pub fn budget_status(&self) -> BudgetStatus
Sourcepub fn format_bar(&self, model: &str, security_mode: &str) -> String
pub fn format_bar(&self, model: &str, security_mode: &str) -> String
Format a compact status bar string for the TUI.
Example: claude-sonnet-4-5 ↑12.3K ↓4.1K $0.053 [ask]
Trait Implementations§
Source§impl Clone for UsageTracker
impl Clone for UsageTracker
Source§fn clone(&self) -> UsageTracker
fn clone(&self) -> UsageTracker
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 UsageTracker
impl Debug for UsageTracker
Source§impl Default for UsageTracker
impl Default for UsageTracker
Source§fn default() -> UsageTracker
fn default() -> UsageTracker
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for UsageTracker
impl RefUnwindSafe for UsageTracker
impl Send for UsageTracker
impl Sync for UsageTracker
impl Unpin for UsageTracker
impl UnsafeUnpin for UsageTracker
impl UnwindSafe for UsageTracker
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