pub struct TokenLimits<R: ModelLimitResolver> { /* private fields */ }Expand description
Token limit lookup service for model specifications.
Wraps a ModelLimitResolver to provide token limit queries
and usage percentage calculations for sessions.
Implementations§
Source§impl<R: ModelLimitResolver> TokenLimits<R>
impl<R: ModelLimitResolver> TokenLimits<R>
Sourcepub fn get_limit(&self, model: &str) -> Option<TokenLimit>
pub fn get_limit(&self, model: &str) -> Option<TokenLimit>
Get token limit for a model by name.
Returns None if the model is not recognized by the resolver.
Sourcepub fn get_usage_percentage_from_state(
&self,
state: &SessionState,
) -> Option<(f64, f64, f64)>
pub fn get_usage_percentage_from_state( &self, state: &SessionState, ) -> Option<(f64, f64, f64)>
Calculate usage percentages from session state.
Returns (input_pct, output_pct, total_pct) where each is
a percentage (0-100+) relative to the context window limit.
Returns None if model or limit information is unavailable.
Auto Trait Implementations§
impl<R> Freeze for TokenLimits<R>where
R: Freeze,
impl<R> RefUnwindSafe for TokenLimits<R>where
R: RefUnwindSafe,
impl<R> Send for TokenLimits<R>where
R: Send,
impl<R> Sync for TokenLimits<R>where
R: Sync,
impl<R> Unpin for TokenLimits<R>where
R: Unpin,
impl<R> UnwindSafe for TokenLimits<R>where
R: UnwindSafe,
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