pub struct TokenLimit {
pub total_limit: u64,
pub compaction_buffer_pct: f64,
}Expand description
Context window limit configuration for a model.
Defines the total token limit and reserved buffer percentage for context management operations.
Fields§
§total_limit: u64Total context window size in tokens.
compaction_buffer_pct: f64Percentage of context reserved for compaction/management (0-100).
Implementations§
Source§impl TokenLimit
impl TokenLimit
Sourcepub fn new(total_limit: u64, compaction_buffer_pct: f64) -> TokenLimit
pub fn new(total_limit: u64, compaction_buffer_pct: f64) -> TokenLimit
Create a new token limit with validation.
§Panics
Panics if compaction_buffer_pct is not in range 0-100.
Sourcepub fn effective_limit(&self) -> u64
pub fn effective_limit(&self) -> u64
Calculate effective usable token limit after buffer reservation.
Returns the actual number of tokens available for use after subtracting the compaction buffer.
Trait Implementations§
Source§impl Clone for TokenLimit
impl Clone for TokenLimit
Source§fn clone(&self) -> TokenLimit
fn clone(&self) -> TokenLimit
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 moreAuto Trait Implementations§
impl Freeze for TokenLimit
impl RefUnwindSafe for TokenLimit
impl Send for TokenLimit
impl Sync for TokenLimit
impl Unpin for TokenLimit
impl UnwindSafe for TokenLimit
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