pub struct ModelLimitsRegistry { /* private fields */ }Expand description
Registry for model limits with built-in defaults and user overrides.
Implementations§
Source§impl ModelLimitsRegistry
impl ModelLimitsRegistry
Sourcepub fn with_config_path(path: impl Into<PathBuf>) -> Self
pub fn with_config_path(path: impl Into<PathBuf>) -> Self
Create a registry with a specific config file path.
Sourcepub async fn load_user_config(&mut self) -> Result<()>
pub async fn load_user_config(&mut self) -> Result<()>
Load user overrides from the default configuration path.
Default path: {bamboo_data_dir}/model_limits.json
Sourcepub fn add_limit(&mut self, limit: ModelLimit)
pub fn add_limit(&mut self, limit: ModelLimit)
Add a user limit override.
Sourcepub fn get(&self, model: &str) -> Option<ModelLimit>
pub fn get(&self, model: &str) -> Option<ModelLimit>
Get limit for a model, with user overrides taking priority.
Returns None if no matching limit is found.
§Matching Strategy
- Exact match (highest priority)
- Model contains pattern (e.g., “gpt-4o-mini” contains “gpt-4o”)
- Pattern contains model (e.g., “gpt-4” contains “gpt”)
For partial matches, the longest (most specific) pattern wins.
Sourcepub fn get_or_default(&self, model: &str) -> ModelLimit
pub fn get_or_default(&self, model: &str) -> ModelLimit
Get limit for a model with fallback to default.
Sourcepub async fn save_user_config(&self) -> Result<()>
pub async fn save_user_config(&self) -> Result<()>
Save current user limits to the configuration file.
Sourcepub fn list_user_limits(&self) -> Vec<&ModelLimit>
pub fn list_user_limits(&self) -> Vec<&ModelLimit>
List all user-defined limits.
Trait Implementations§
Source§impl Clone for ModelLimitsRegistry
impl Clone for ModelLimitsRegistry
Source§fn clone(&self) -> ModelLimitsRegistry
fn clone(&self) -> ModelLimitsRegistry
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 ModelLimitsRegistry
impl Debug for ModelLimitsRegistry
Auto Trait Implementations§
impl Freeze for ModelLimitsRegistry
impl RefUnwindSafe for ModelLimitsRegistry
impl Send for ModelLimitsRegistry
impl Sync for ModelLimitsRegistry
impl Unpin for ModelLimitsRegistry
impl UnsafeUnpin for ModelLimitsRegistry
impl UnwindSafe for ModelLimitsRegistry
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