pub struct CodexTokenTotals {
pub input_tokens: i64,
pub cached_input_tokens: i64,
pub output_tokens: i64,
pub reasoning_output_tokens: i64,
pub total_tokens: i64,
}Expand description
Snapshot of Codex’s cumulative total_token_usage counters.
Codex publishes a whole-session running total on every token_count
event. Attribution therefore works on the delta between consecutive
snapshots, so a mid-session model switch bills each model only for the
tokens produced while it was current instead of double-counting the
pre-switch prefix under both models.
Fields§
§input_tokens: i64§cached_input_tokens: i64§output_tokens: i64§reasoning_output_tokens: i64§total_tokens: i64Implementations§
Source§impl CodexTokenTotals
impl CodexTokenTotals
Sourcepub fn from_total_object(total: &Map<String, Value>) -> Self
pub fn from_total_object(total: &Map<String, Value>) -> Self
Reads the cumulative counters out of a total_token_usage object,
treating missing or non-integer fields as 0.
Sourcepub fn delta_fields(
total: &Map<String, Value>,
prev: Option<&Self>,
) -> Map<String, Value>
pub fn delta_fields( total: &Map<String, Value>, prev: Option<&Self>, ) -> Map<String, Value>
Builds the per-event delta map against prev, keeping only the keys
actually present in total so absent fields stay absent downstream.
A drop in total_tokens means the counter restarted (never observed
in real logs, but cheap to guard): the event is treated as the start
of a new segment rather than clamping every field to zero, which
would silently drop the new segment’s early tokens.
Trait Implementations§
Source§impl Clone for CodexTokenTotals
impl Clone for CodexTokenTotals
Source§fn clone(&self) -> CodexTokenTotals
fn clone(&self) -> CodexTokenTotals
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CodexTokenTotals
Source§impl Debug for CodexTokenTotals
impl Debug for CodexTokenTotals
Source§impl Default for CodexTokenTotals
impl Default for CodexTokenTotals
Source§fn default() -> CodexTokenTotals
fn default() -> CodexTokenTotals
impl Eq for CodexTokenTotals
Source§impl PartialEq for CodexTokenTotals
impl PartialEq for CodexTokenTotals
impl StructuralPartialEq for CodexTokenTotals
Auto Trait Implementations§
impl Freeze for CodexTokenTotals
impl RefUnwindSafe for CodexTokenTotals
impl Send for CodexTokenTotals
impl Sync for CodexTokenTotals
impl Unpin for CodexTokenTotals
impl UnsafeUnpin for CodexTokenTotals
impl UnwindSafe for CodexTokenTotals
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<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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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