pub struct SegmentBudget {
pub segment_type: ContextSegmentType,
pub max_tokens: usize,
pub current_tokens: usize,
pub reserved_tokens: usize,
pub can_borrow: bool,
pub can_lend: bool,
}Expand description
Token allocation for a segment type
Matches segmentBudgetSchema in @enact/schemas
Fields§
§segment_type: ContextSegmentTypeSegment type
max_tokens: usizeMaximum tokens for this segment
current_tokens: usizeCurrent token usage
reserved_tokens: usizeReserved tokens (cannot be used by other segments)
can_borrow: boolWhether this segment can borrow from others
can_lend: boolWhether this segment can lend to others
Implementations§
Source§impl SegmentBudget
impl SegmentBudget
Sourcepub fn new(segment_type: ContextSegmentType, max_tokens: usize) -> Self
pub fn new(segment_type: ContextSegmentType, max_tokens: usize) -> Self
Create a new segment budget
Sourcepub fn usage_percent(&self) -> u8
pub fn usage_percent(&self) -> u8
Usage percentage (0-100)
Sourcepub fn is_over_budget(&self) -> bool
pub fn is_over_budget(&self) -> bool
Whether this segment is over budget
Trait Implementations§
Source§impl Clone for SegmentBudget
impl Clone for SegmentBudget
Source§fn clone(&self) -> SegmentBudget
fn clone(&self) -> SegmentBudget
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 SegmentBudget
impl Debug for SegmentBudget
Source§impl<'de> Deserialize<'de> for SegmentBudget
impl<'de> Deserialize<'de> for SegmentBudget
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
Auto Trait Implementations§
impl Freeze for SegmentBudget
impl RefUnwindSafe for SegmentBudget
impl Send for SegmentBudget
impl Sync for SegmentBudget
impl Unpin for SegmentBudget
impl UnsafeUnpin for SegmentBudget
impl UnwindSafe for SegmentBudget
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