pub struct UsageData {
pub models: UsageResult,
pub per_provider: PerProviderUsage,
pub provider_days: ProviderActiveDays,
pub stored_costs: StoredCosts,
}Expand description
Aggregated token usage plus the per-provider active-day counts.
Built only by aggregate_usage_from_home; all fields are public for the
display layer to read. Token totals are tracked two ways at once because the
two views need different attribution: models merges a
shared model (e.g. claude-sonnet-4-6 emitted by both Claude Code and
Copilot CLI) into one row, while per_provider
keeps the same tokens scoped to the source directory so the footer can
attribute them correctly. The shared tokens are merged, not summed, so they
are never double-counted across the two maps.
§Examples
use vct_core::{aggregate_usage_from_home, TimeRange};
let data = aggregate_usage_from_home(TimeRange::All)?;
// Total distinct days that contributed any usage, across all providers.
println!("active days: {}", data.provider_days.total);Fields§
§models: UsageResultTokens aggregated across all providers, keyed by model name.
Drives the per-model summary table where, e.g., claude-sonnet-4-6
tokens from Claude Code and Copilot CLI share a single row.
per_provider: PerProviderUsageTokens kept separate per source directory, keyed by provider → model.
Drives the per-provider totals in the summary footer. Keeping this split at aggregation time avoids the display layer from having to guess a model’s provider from its name, which broke once Copilot CLI started emitting real (Claude / OpenAI / …) model names.
provider_days: ProviderActiveDaysCount of distinct calendar dates that contributed usage, per provider and overall.
stored_costs: StoredCostsProvider-authoritative per-model cost (USD), summed from the source.
Implementations§
Source§impl UsageData
impl UsageData
Sourcepub fn provider_usage(&self, provider: Provider) -> Option<&UsageResult>
pub fn provider_usage(&self, provider: Provider) -> Option<&UsageResult>
Returns the per-provider usage slice for provider, or None
when the provider has no dedicated bucket (e.g. Provider::Unknown
— the display layer’s fallthrough view is fed by the global
models map instead).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UsageData
impl RefUnwindSafe for UsageData
impl Send for UsageData
impl Sync for UsageData
impl Unpin for UsageData
impl UnsafeUnpin for UsageData
impl UnwindSafe for UsageData
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
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>
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>
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