pub struct Config {
pub general: General,
pub sources: BTreeMap<String, Source>,
pub pricing: BTreeMap<String, BTreeMap<String, ModelPrice>>,
}Expand description
Loaded configuration, with defaults already applied.
Fields§
§general: General§sources: BTreeMap<String, Source>Source adapters keyed by adapter name, e.g. claude-code.
pricing: BTreeMap<String, BTreeMap<String, ModelPrice>>Per-provider price tables keyed by provider, e.g. anthropic.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load_from_dir(dir: &Path) -> Result<Self, ConfigError>
pub fn load_from_dir(dir: &Path) -> Result<Self, ConfigError>
Read config.toml from dir. A missing file is not an error — it means
“all defaults”.
Sourcepub fn load_file(path: &Path) -> Result<Self, ConfigError>
pub fn load_file(path: &Path) -> Result<Self, ConfigError>
Read a specific config file. A missing file yields the defaults.
Sourcepub fn source(&self, adapter: &str) -> Source
pub fn source(&self, adapter: &str) -> Source
Configured source settings, or the defaults for an unconfigured adapter.
Sourcepub fn price(&self, provider: &str, model: &str) -> Option<ModelPrice>
pub fn price(&self, provider: &str, model: &str) -> Option<ModelPrice>
Configured price for a model, if any.
Sourcepub fn estimate_cost(
&self,
provider: &str,
model: &str,
tokens: TokenCounts,
) -> Option<f64>
pub fn estimate_cost( &self, provider: &str, model: &str, tokens: TokenCounts, ) -> Option<f64>
Estimate cost in whole currency units for the given token counts.
Returns None when the model has no configured price — callers must
propagate the absence rather than substituting 0.0.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
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 Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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