pub struct ModelSpec {
pub prefix: &'static str,
pub context_window: u64,
pub compaction_buffer_pct: f64,
}Expand description
Model specification with named fields for type safety
NOTE: Why struct instead of tuple (&str, u64)? Tuples are position-dependent and lack semantic meaning:
- (“claude-3-5”, 200_000) vs (200_000, “claude-3-5”) - compiler can’t catch order mistakes
- No field names make code less self-documenting
- Hard to extend (adding output_limit would create complex tuples)
Structs provide:
- Named fields prevent position errors (can’t swap prefix and context_window)
- Self-documenting code (field names explain purpose)
- Easy to extend with new fields (e.g., output_limit, cache_support)
- IDE auto-completion works
- Compiler enforces all fields are provided
Fields§
§prefix: &'static str§context_window: u64§compaction_buffer_pct: f64Compaction buffer percentage (0-100) When input tokens exceed (100% - compaction_buffer_pct), compaction is triggered
Implementations§
Trait Implementations§
impl Copy for ModelSpec
impl StructuralPartialEq for ModelSpec
Auto Trait Implementations§
impl Freeze for ModelSpec
impl RefUnwindSafe for ModelSpec
impl Send for ModelSpec
impl Sync for ModelSpec
impl Unpin for ModelSpec
impl UnwindSafe for ModelSpec
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