pub struct ContextLimit(/* private fields */);Expand description
Context window limit (maximum tokens allowed)
Implementations§
Source§impl ContextLimit
impl ContextLimit
pub const fn new(value: u64) -> Self
pub const fn as_u64(self) -> u64
Sourcepub fn usage_ratio(self, used: TokenCount) -> f64
pub fn usage_ratio(self, used: TokenCount) -> f64
Calculate usage ratio (0.0 to 1.0+)
Sourcepub fn remaining(self, used: TokenCount) -> TokenCount
pub fn remaining(self, used: TokenCount) -> TokenCount
Calculate remaining capacity
Sourcepub fn is_exceeded(self, used: TokenCount) -> bool
pub fn is_exceeded(self, used: TokenCount) -> bool
Check if usage exceeds limit
Sourcepub fn is_warning_zone(self, used: TokenCount) -> bool
pub fn is_warning_zone(self, used: TokenCount) -> bool
Check if usage is in warning zone (>80%)
Sourcepub fn is_danger_zone(self, used: TokenCount) -> bool
pub fn is_danger_zone(self, used: TokenCount) -> bool
Check if usage is in danger zone (>90%)
Trait Implementations§
Source§impl Clone for ContextLimit
impl Clone for ContextLimit
Source§fn clone(&self) -> ContextLimit
fn clone(&self) -> ContextLimit
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextLimit
impl Debug for ContextLimit
Source§impl<'de> Deserialize<'de> for ContextLimit
impl<'de> Deserialize<'de> for ContextLimit
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 From<u64> for ContextLimit
impl From<u64> for ContextLimit
Source§impl Ord for ContextLimit
impl Ord for ContextLimit
Source§fn cmp(&self, other: &ContextLimit) -> Ordering
fn cmp(&self, other: &ContextLimit) -> Ordering
1.21.0 · 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
Source§impl PartialEq for ContextLimit
impl PartialEq for ContextLimit
Source§impl PartialOrd for ContextLimit
impl PartialOrd for ContextLimit
Source§impl Serialize for ContextLimit
impl Serialize for ContextLimit
impl Copy for ContextLimit
impl Eq for ContextLimit
impl StructuralPartialEq for ContextLimit
Auto Trait Implementations§
impl Freeze for ContextLimit
impl RefUnwindSafe for ContextLimit
impl Send for ContextLimit
impl Sync for ContextLimit
impl Unpin for ContextLimit
impl UnwindSafe for ContextLimit
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