pub struct Usage {
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_read_tokens: Option<u64>,
pub cache_creation_tokens: Option<u64>,
pub reasoning_tokens: Option<u64>,
}Expand description
Token accounting parsed from the provider’s terminal usage event.
Fields§
§input_tokens: u64Input (prompt) tokens.
output_tokens: u64Output (completion) tokens.
cache_read_tokens: Option<u64>Tokens served from the prompt cache. None = this wire/provider does
not report the counter; Some(0) = reported as zero (a real signal:
no cache hit). ADR-0009 amendment 2026-07-19 — zero-as-N/A rejected.
cache_creation_tokens: Option<u64>Tokens written to the prompt cache (None on wires that never report
writes, e.g. the OpenAI family).
reasoning_tokens: Option<u64>Reasoning/thinking tokens (None on wires that fold them into
output_tokens, e.g. Anthropic).
Trait Implementations§
Source§impl AddAssign for Usage
impl AddAssign for Usage
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Accumulate another turn’s usage field-wise (the engine sums across turns).
impl Copy for Usage
Source§impl<'de> Deserialize<'de> for Usage
impl<'de> Deserialize<'de> for Usage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Usage
impl StructuralPartialEq for Usage
Auto Trait Implementations§
impl Freeze for Usage
impl RefUnwindSafe for Usage
impl Send for Usage
impl Sync for Usage
impl Unpin for Usage
impl UnsafeUnpin for Usage
impl UnwindSafe for Usage
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