pub struct Usage {
pub prompt: u64,
pub completion: u64,
pub cache_read: u64,
pub cache_creation: u64,
}Fields§
§prompt: u64§completion: u64§cache_read: u64§cache_creation: u64Implementations§
Source§impl Usage
impl Usage
pub fn add(&mut self, other: &Usage)
Sourcepub fn from_openai(usage: &Value) -> Usage
pub fn from_openai(usage: &Value) -> Usage
Parse an OpenAI-style usage object:
{ prompt_tokens, completion_tokens, prompt_tokens_details: { cached_tokens } }.
Sourcepub fn from_anthropic(usage: &Value) -> Usage
pub fn from_anthropic(usage: &Value) -> Usage
Parse an Anthropic-style usage object (the claude CLI result event):
{ input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens }.
Sourcepub fn from_cursor(usage: &Value) -> Usage
pub fn from_cursor(usage: &Value) -> Usage
Parse a cursor-agent result-event usage object (camelCase):
{ inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens }.
Sourcepub fn from_any(usage: &Value) -> Usage
pub fn from_any(usage: &Value) -> Usage
Parse a usage object that may be in either OpenAI or Anthropic shape
(used for subprocess backends whose event schema is less certain).
pub fn to_json(self) -> Value
One-line footer: prompt:24.3k tokens:515 (cache_r/cache_w shown only
when nonzero).
Trait Implementations§
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