pub struct UsageReport {
pub budget_requested: u32,
pub budget_consumed: u64,
pub as_of: String,
pub providers: Vec<ProviderUsage>,
}Expand description
A per-request roll-up of context cost across every provider a query fanned
out to (docs/context-reuse.md §2).
This is the shape a host maps into a metering pipeline: one row per
(request, provider) with a frame-cited token total, plus the request-level
budget requested vs. consumed and the accounting snapshot time.
Fields§
§budget_requested: u32The query’s max_tokens — the budget the host asked providers to
respect.
budget_consumed: u64The summed token_cost of every served frame across all providers —
what the request actually consumed.
as_of: StringThe accounting snapshot time (RFC 3339), supplied by the host that
produced the report. This is the report’s as-of, distinct from a
query’s bi-temporal as_of retrieval pin.
providers: Vec<ProviderUsage>Per-provider usage, one entry per provider the query fanned out to.
Implementations§
Source§impl UsageReport
impl UsageReport
Sourcepub fn total_provider_cost(&self) -> u64
pub fn total_provider_cost(&self) -> u64
Re-sum every provider’s token_cost. Equals budget_consumed
for a consistently-built report.
Sourcepub fn total_frames_served(&self) -> u64
pub fn total_frames_served(&self) -> u64
The number of frames served across all providers.
Sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
The core arithmetic identity a metering pipeline checks before trusting the report: the consumed total equals the summed cost of every served frame, and each provider’s aggregate agrees with its itemized frames. A report that fails this is a corrupted total, never a silent misbill (§2 conformance).
Sourcepub fn within_budget(&self) -> bool
pub fn within_budget(&self) -> bool
Whether the request stayed within its requested budget. A conformant host drops budget-lying providers before they reach a report, so a report built by such a host always satisfies this.
Trait Implementations§
Source§impl Clone for UsageReport
impl Clone for UsageReport
Source§fn clone(&self) -> UsageReport
fn clone(&self) -> UsageReport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more