#[non_exhaustive]pub struct Usage {
pub total_tokens: u64,
pub input_tokens: u64,
pub output_tokens: u64,
pub thought_tokens: Option<u64>,
pub cached_read_tokens: Option<u64>,
pub cached_write_tokens: Option<u64>,
pub meta: Option<Map<String, Value>>,
}unstable_protocol_v2 only.Expand description
UNSTABLE
This capability is not part of the spec yet, and may be removed or changed at any point.
Token usage for the foreground work that just completed, not cumulative for the session.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.total_tokens: u64Sum of all token types for the completed work.
input_tokens: u64Input tokens for the completed work.
output_tokens: u64Output tokens for the completed work.
thought_tokens: Option<u64>Thought/reasoning tokens for the completed work.
Omitted and null are equivalent and mean the count is not reported.
cached_read_tokens: Option<u64>Cache read tokens for the completed work.
Omitted and null are equivalent and mean the count is not reported.
cached_write_tokens: Option<u64>Cache write tokens for the completed work.
Omitted and null are equivalent and mean the count is not reported.
meta: Option<Map<String, Value>>The _meta property is reserved by ACP to allow Clients and Agents to attach additional
metadata to their interactions. Omitted and null are equivalent and mean no metadata.
Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
Implementations§
Source§impl Usage
impl Usage
Sourcepub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn new(total_tokens: u64, input_tokens: u64, output_tokens: u64) -> Usage
unstable_end_turn_token_usage only.Builds Usage with the required fields set. Optional fields start unset or empty.
Sourcepub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn thought_tokens(self, thought_tokens: impl IntoOption<u64>) -> Usage
unstable_end_turn_token_usage only.Thought/reasoning tokens for the completed work.
Sourcepub fn cached_read_tokens(
self,
cached_read_tokens: impl IntoOption<u64>,
) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_read_tokens( self, cached_read_tokens: impl IntoOption<u64>, ) -> Usage
unstable_end_turn_token_usage only.Cache read tokens for the completed work.
Sourcepub fn cached_write_tokens(
self,
cached_write_tokens: impl IntoOption<u64>,
) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn cached_write_tokens( self, cached_write_tokens: impl IntoOption<u64>, ) -> Usage
unstable_end_turn_token_usage only.Cache write tokens for the completed work.
Sourcepub fn meta(self, meta: impl IntoOption<Map<String, Value>>) -> Usage
Available on crate feature unstable_end_turn_token_usage only.
pub fn meta(self, meta: impl IntoOption<Map<String, Value>>) -> Usage
unstable_end_turn_token_usage only.The _meta property is reserved by ACP to allow Clients and Agents to attach additional metadata to their interactions. Implementations MUST NOT assign meaning to keys they do not recognize.
See protocol docs: Extensibility
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Usage
impl<'de> Deserialize<'de> for Usage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Usage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Usage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Usage
Source§impl JsonSchema for Usage
impl JsonSchema for Usage
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Serialize for Usage
impl Serialize for Usage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Usage
Auto Trait Implementations§
impl Forget for Usage
impl Freeze for Usage
impl Move 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
key and return true if they are equal.