pub struct TokenCount(/* private fields */);Expand description
A count of model input, cached-input, reasoning, or output tokens.
The JSON wire form is a canonical unsigned decimal string. Arithmetic is available only through checked methods, so release builds cannot silently wrap accounting values.
Implementations§
Source§impl TokenCount
impl TokenCount
Sourcepub const fn checked_add(self, other: Self) -> Option<Self>
pub const fn checked_add(self, other: Self) -> Option<Self>
Adds two counts, returning None on overflow.
Sourcepub const fn checked_sub(self, other: Self) -> Option<Self>
pub const fn checked_sub(self, other: Self) -> Option<Self>
Subtracts two counts, returning None on underflow.
Sourcepub const fn checked_mul(self, multiplier: u64) -> Option<Self>
pub const fn checked_mul(self, multiplier: u64) -> Option<Self>
Multiplies a count by an integer, returning None on overflow.
Trait Implementations§
Source§impl Clone for TokenCount
impl Clone for TokenCount
impl Copy for TokenCount
Source§impl Debug for TokenCount
impl Debug for TokenCount
Source§impl Default for TokenCount
impl Default for TokenCount
Source§impl<'de> Deserialize<'de> for TokenCount
impl<'de> Deserialize<'de> for TokenCount
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 Display for TokenCount
impl Display for TokenCount
impl Eq for TokenCount
Source§impl From<TokenCount> for u64
impl From<TokenCount> for u64
Source§fn from(value: TokenCount) -> Self
fn from(value: TokenCount) -> Self
Converts to this type from the input type.
Source§impl From<u64> for TokenCount
impl From<u64> for TokenCount
Source§impl FromStr for TokenCount
impl FromStr for TokenCount
Source§impl Hash for TokenCount
impl Hash for TokenCount
Source§impl JsonSchema for TokenCount
impl JsonSchema for TokenCount
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for TokenCount
impl Ord for TokenCount
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for TokenCount
impl PartialEq for TokenCount
Source§impl PartialOrd for TokenCount
impl PartialOrd for TokenCount
Source§impl Serialize for TokenCount
impl Serialize for TokenCount
impl StructuralPartialEq for TokenCount
Auto Trait Implementations§
impl Forget for TokenCount
impl Freeze for TokenCount
impl Move for TokenCount
impl RefUnwindSafe for TokenCount
impl Send for TokenCount
impl Sync for TokenCount
impl Unpin for TokenCount
impl UnsafeUnpin for TokenCount
impl UnwindSafe for TokenCount
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