pub struct TokenCounts {
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_creation_tokens: u64,
pub cache_read_tokens: u64,
}Expand description
Token counts for usage tracking
This struct tracks all types of tokens consumed during Claude API usage, including input, output, and cache-related tokens.
§Examples
use ccstat::types::TokenCounts;
let tokens = TokenCounts::new(100, 50, 10, 5);
assert_eq!(tokens.total(), 165);
// TokenCounts supports arithmetic operations
let tokens2 = TokenCounts::new(50, 25, 5, 2);
let combined = tokens + tokens2;
assert_eq!(combined.input_tokens, 150);Fields§
§input_tokens: u64Input tokens used
output_tokens: u64Output tokens generated
cache_creation_tokens: u64Cache creation tokens
cache_read_tokens: u64Cache read tokens
Implementations§
Trait Implementations§
Source§impl Add for TokenCounts
impl Add for TokenCounts
Source§impl AddAssign for TokenCounts
impl AddAssign for TokenCounts
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl Clone for TokenCounts
impl Clone for TokenCounts
Source§fn clone(&self) -> TokenCounts
fn clone(&self) -> TokenCounts
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 TokenCounts
impl Debug for TokenCounts
Source§impl Default for TokenCounts
impl Default for TokenCounts
Source§fn default() -> TokenCounts
fn default() -> TokenCounts
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for TokenCounts
impl<'de> Deserialize<'de> for TokenCounts
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
Source§impl PartialEq for TokenCounts
impl PartialEq for TokenCounts
Source§impl Serialize for TokenCounts
impl Serialize for TokenCounts
impl Copy for TokenCounts
impl Eq for TokenCounts
impl StructuralPartialEq for TokenCounts
Auto Trait Implementations§
impl Freeze for TokenCounts
impl RefUnwindSafe for TokenCounts
impl Send for TokenCounts
impl Sync for TokenCounts
impl Unpin for TokenCounts
impl UnwindSafe for TokenCounts
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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