pub struct ResourceTelemetry {
pub tokens_used: u64,
pub time_used_seconds: u64,
pub token_budget: Option<u64>,
pub time_budget_seconds: Option<u64>,
}Expand description
A snapshot of token and time usage for a single task, with optional budgets.
All fields are plain counters; this type owns no clock and reads no environment. Construct it from whatever the caller is already tracking and use the helpers below to render or classify it.
Fields§
§tokens_used: u64Total tokens consumed so far.
time_used_seconds: u64Total wall-clock seconds elapsed so far.
token_budget: Option<u64>Optional token ceiling for the task; None means unbounded.
time_budget_seconds: Option<u64>Optional time ceiling in seconds; None means unbounded.
Implementations§
Source§impl ResourceTelemetry
impl ResourceTelemetry
Sourcepub fn new(tokens_used: u64, time_used_seconds: u64) -> Self
pub fn new(tokens_used: u64, time_used_seconds: u64) -> Self
Create a telemetry snapshot with no budgets (fully unbounded).
Sourcepub fn with_token_budget(self, budget: u64) -> Self
pub fn with_token_budget(self, budget: u64) -> Self
Set the token budget, returning the updated snapshot (builder style).
Sourcepub fn with_time_budget_seconds(self, seconds: u64) -> Self
pub fn with_time_budget_seconds(self, seconds: u64) -> Self
Set the time budget in seconds, returning the updated snapshot.
Sourcepub fn token_fraction(&self) -> Option<f64>
pub fn token_fraction(&self) -> Option<f64>
Fraction of the token budget consumed, or None when unbounded.
A zero budget yields None (a percentage of nothing is meaningless)
rather than infinity, keeping every downstream consumer safe.
Sourcepub fn time_fraction(&self) -> Option<f64>
pub fn time_fraction(&self) -> Option<f64>
Fraction of the time budget consumed, or None when unbounded.
Sourcepub fn budget_fraction(&self) -> Option<f64>
pub fn budget_fraction(&self) -> Option<f64>
The largest bounded budget fraction across tokens and time.
Returns None only when neither dimension is bounded. When at least
one budget is present, the most-pressured bounded dimension wins.
Sourcepub fn budget_percent(&self) -> Option<u64>
pub fn budget_percent(&self) -> Option<u64>
Budget fraction expressed as a whole-number percent (rounded), or None
when unbounded. This is the value surfaced in the human summary.
Sourcepub fn pressure(&self) -> PressureLevel
pub fn pressure(&self) -> PressureLevel
Coarse pressure level derived from Self::budget_fraction.
Unbounded tasks are always PressureLevel::Low.
Sourcepub fn human_summary(&self) -> String
pub fn human_summary(&self) -> String
A compact, human-readable one-liner, e.g. 12.3k tok · 4m12s · 41% budget.
Tokens are abbreviated with k/M suffixes, time is rendered as
Hh Mm Ss (dropping leading zero units), and the budget segment is
omitted entirely when the task is unbounded.
Trait Implementations§
Source§impl Clone for ResourceTelemetry
impl Clone for ResourceTelemetry
impl Copy for ResourceTelemetry
Source§impl Debug for ResourceTelemetry
impl Debug for ResourceTelemetry
Source§impl Default for ResourceTelemetry
impl Default for ResourceTelemetry
Source§impl Display for ResourceTelemetry
impl Display for ResourceTelemetry
impl Eq for ResourceTelemetry
Source§impl PartialEq for ResourceTelemetry
impl PartialEq for ResourceTelemetry
impl StructuralPartialEq for ResourceTelemetry
Auto Trait Implementations§
impl Freeze for ResourceTelemetry
impl RefUnwindSafe for ResourceTelemetry
impl Send for ResourceTelemetry
impl Sync for ResourceTelemetry
impl Unpin for ResourceTelemetry
impl UnsafeUnpin for ResourceTelemetry
impl UnwindSafe for ResourceTelemetry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.