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 registry’s configured path.
No-op when the registry was created without a config_path (use
Self::with_config_path — e.g. with get_default_config_path — to
point it at {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”)
For partial matches, the longest (most specific) pattern wins.
Only the model.contains(pattern) direction is correct: the configured
pattern must be a substring of the runtime model id. The reverse
(pattern.contains(model)) was a bug (#20, bug 3) — it let a short model
id like "gpt-4o" match a longer, unrelated pattern like "gpt-4o-mini"
and inherit the wrong limit.
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 configured file.
No-op when the registry has no config_path.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more