pub trait GetTokenUsage {
// Required method
fn token_usage(&self) -> Usage;
}Expand description
A trait for grabbing the token usage of a completion response.
Primarily designed for streamed completion responses in streamed multi-turn, as otherwise it would be impossible to do.
Required Methods§
Sourcefn token_usage(&self) -> Usage
fn token_usage(&self) -> Usage
Returns token usage for this response. Zero-valued usage is
Usage’s documented sentinel for missing provider usage metrics;
response types that carry no usage return Usage::new.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".