pub struct Config {Show 14 fields
pub import: Vec<String>,
pub root: bool,
pub leases: IndexMap<String, LeaseBackendConfig>,
pub providers: IndexMap<String, ProviderConfig>,
pub secrets: IndexMap<String, SecretConfig>,
pub profiles: IndexMap<String, ProfileConfig>,
pub age_key_file: Option<PathBuf>,
pub if_missing: Option<IfMissing>,
pub prompt_auth: Option<bool>,
pub mcp: Option<McpConfig>,
pub provider_sources: HashMap<String, PathBuf>,
pub secret_sources: HashMap<String, PathBuf>,
pub default_provider_source: Option<PathBuf>,
pub project_dir: Option<PathBuf>,
/* private fields */
}Fields§
§import: Vec<String>Import paths to other config files
root: boolRoot configuration - stops recursion at this level
leases: IndexMap<String, LeaseBackendConfig>Lease backend configurations (for default profile)
providers: IndexMap<String, ProviderConfig>Provider configurations (for default profile)
secrets: IndexMap<String, SecretConfig>Default profile secrets (top level)
profiles: IndexMap<String, ProfileConfig>Named profiles
age_key_file: Option<PathBuf>Age encryption key file path (optional, can also be set via env var or CLI flag)
if_missing: Option<IfMissing>Default if_missing behavior for all secrets in this config
prompt_auth: Option<bool>Whether to prompt for authentication when provider auth fails (default: true in TTY)
mcp: Option<McpConfig>MCP server configuration
provider_sources: HashMap<String, PathBuf>Track which config file each provider came from (not serialized)
secret_sources: HashMap<String, PathBuf>Track which config file each secret came from (not serialized)
default_provider_source: Option<PathBuf>Track which config file the default_provider came from (not serialized)
project_dir: Option<PathBuf>The project root directory — the nearest directory to cwd that contains a config file. Used for scoping the lease ledger per-project.
Implementations§
Source§impl Config
impl Config
Sourcepub fn load_smart<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_smart<P: AsRef<Path>>(path: P) -> Result<Self>
Load configuration using the appropriate strategy
Sourcepub fn global_config_path() -> PathBuf
pub fn global_config_path() -> PathBuf
Get the path to the global config file
Sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save configuration to a file Uses toml_edit to preserve insertion order from IndexMap and format secrets as inline tables
Sourcepub fn save_secret_to_source(
&self,
secret_name: &str,
secret_config: &SecretConfig,
profile: &str,
default_target: &Path,
) -> Result<()>
pub fn save_secret_to_source( &self, secret_name: &str, secret_config: &SecretConfig, profile: &str, default_target: &Path, ) -> Result<()>
Save a single secret update back to its source file Always saves to the default_target (local config file), creating a local override if the secret exists in a parent config. This aligns with the hierarchical config model where child configs override parent configs.
This method preserves comments and formatting in the TOML file by directly manipulating the document AST rather than re-serializing.
Sourcepub fn remove_secret_from_source(
secret_name: &str,
profile: &str,
target_file: &Path,
) -> Result<bool>
pub fn remove_secret_from_source( secret_name: &str, profile: &str, target_file: &Path, ) -> Result<bool>
Remove a single secret from a config file, preserving comments and formatting.
This method directly manipulates the TOML document AST rather than re-serializing, so all comments, whitespace, and formatting are preserved.
Sourcepub fn save_secrets_to_source(
secrets: &IndexMap<String, SecretConfig>,
profile: &str,
target_file: &Path,
) -> Result<()>
pub fn save_secrets_to_source( secrets: &IndexMap<String, SecretConfig>, profile: &str, target_file: &Path, ) -> Result<()>
Save multiple secrets to a config file, preserving comments and formatting.
This is the batch equivalent of save_secret_to_source, used by fnox import.
Sourcepub fn get_profile(profile_flag: Option<&str>) -> String
pub fn get_profile(profile_flag: Option<&str>) -> String
Get the profile to use (from flag or env var, defaulting to “default”)
Sourcepub fn should_prompt_auth(&self) -> bool
pub fn should_prompt_auth(&self) -> bool
Determine if we should prompt for authentication when provider auth fails. Priority: env var > config > default (true) Returns true only if prompting is enabled AND we’re in a TTY.
Sourcepub fn get_default_secrets_mut(&mut self) -> &mut IndexMap<String, SecretConfig>
pub fn get_default_secrets_mut(&mut self) -> &mut IndexMap<String, SecretConfig>
Get secrets for the default profile (mutable)
Sourcepub fn get_profile_secrets_mut(
&mut self,
profile: &str,
) -> &mut IndexMap<String, SecretConfig>
pub fn get_profile_secrets_mut( &mut self, profile: &str, ) -> &mut IndexMap<String, SecretConfig>
Get secrets for a specific profile (mutable)
Sourcepub fn get_secrets(
&self,
profile: &str,
) -> Result<IndexMap<String, SecretConfig>>
pub fn get_secrets( &self, profile: &str, ) -> Result<IndexMap<String, SecretConfig>>
Get effective secrets (default or profile) For non-default profiles, this merges top-level secrets with profile-specific secrets, with profile secrets taking precedence.
Note: If a profile doesn’t exist in [profiles], it’s treated as “default”. This allows fnox.$FNOX_PROFILE.toml files to work without requiring a [profiles] section.
Sourcepub fn get_secret(&self, profile: &str, key: &str) -> Option<&SecretConfig>
pub fn get_secret(&self, profile: &str, key: &str) -> Option<&SecretConfig>
Look up a single secret by key without cloning the secrets map.
Mirrors the precedence used by Self::get_secrets: profile-specific
secrets take precedence, falling back to top-level secrets unless
no_defaults is set.
Sourcepub fn get_secrets_mut(
&mut self,
profile: &str,
) -> &mut IndexMap<String, SecretConfig>
pub fn get_secrets_mut( &mut self, profile: &str, ) -> &mut IndexMap<String, SecretConfig>
Get effective secrets (default or profile, mutable)
Sourcepub fn get_leases(&self, profile: &str) -> IndexMap<String, LeaseBackendConfig>
pub fn get_leases(&self, profile: &str) -> IndexMap<String, LeaseBackendConfig>
Get effective lease backends for a profile
Sourcepub fn get_providers(&self, profile: &str) -> IndexMap<String, ProviderConfig>
pub fn get_providers(&self, profile: &str) -> IndexMap<String, ProviderConfig>
Get effective providers for a profile
Sourcepub fn get_default_provider(&self, profile: &str) -> Result<Option<String>>
pub fn get_default_provider(&self, profile: &str) -> Result<Option<String>>
Get the default provider for a profile Returns the configured default_provider, or auto-selects if there’s only one provider
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the configuration Collects all validation issues and returns them together using #[related]
Sourcepub fn default_provider(&self) -> Option<&str>
pub fn default_provider(&self) -> Option<&str>
Get the default provider name, if set.
Sourcepub fn default_provider_span(&self) -> Option<Range<usize>>
pub fn default_provider_span(&self) -> Option<Range<usize>>
Get the default provider’s source span (byte range in the config file). Returns None if the default_provider wasn’t set or was created programmatically.
Sourcepub fn set_default_provider(&mut self, provider: Option<String>)
pub fn set_default_provider(&mut self, provider: Option<String>)
Set the default provider name (without span information).
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>,
Source§impl JsonSchema for Config
impl JsonSchema for Config
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto 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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
impl<D> DeserializeWith<JsonFormat> for Dwhere
D: DeserializeOwned,
Source§fn deserialize_with(body: ResponseBody) -> Result<D, Error>
fn deserialize_with(body: ResponseBody) -> Result<D, Error>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more