pub struct Config { /* private fields */ }Expand description
The main configuration container
Config provides lazy resolution of interpolation expressions and caches resolved values for efficiency.
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_options(value: Value, options: ConfigOptions) -> Self
pub fn with_options(value: Value, options: ConfigOptions) -> Self
Create a Config with custom options
Sourcepub fn with_resolvers(value: Value, resolvers: ResolverRegistry) -> Self
pub fn with_resolvers(value: Value, resolvers: ResolverRegistry) -> Self
Create a Config with a custom resolver registry
Sourcepub fn from_yaml_with_options(
yaml: &str,
options: ConfigOptions,
) -> Result<Self>
pub fn from_yaml_with_options( yaml: &str, options: ConfigOptions, ) -> Result<Self>
Load configuration from a YAML string with options
Sourcepub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self>
Load configuration from a YAML file
Sourcepub fn load_merged<P: AsRef<Path>>(paths: &[P]) -> Result<Self>
pub fn load_merged<P: AsRef<Path>>(paths: &[P]) -> Result<Self>
Load and merge multiple YAML files
Files are merged in order, with later files overriding earlier ones. Per ADR-004:
- Mappings are deep-merged
- Scalars use last-writer-wins
- Arrays are replaced (not concatenated)
- Null values remove keys
Sourcepub fn merge(&mut self, other: Config)
pub fn merge(&mut self, other: Config)
Merge another config into this one
The other config’s values override this config’s values per ADR-004 merge semantics.
Sourcepub fn get(&self, path: &str) -> Result<Value>
pub fn get(&self, path: &str) -> Result<Value>
Get a resolved value at a path
This resolves any interpolation expressions in the value. Resolved values are cached for subsequent accesses.
Sourcepub fn get_string(&self, path: &str) -> Result<String>
pub fn get_string(&self, path: &str) -> Result<String>
Get a resolved string value, with type coercion if needed
Sourcepub fn get_i64(&self, path: &str) -> Result<i64>
pub fn get_i64(&self, path: &str) -> Result<i64>
Get a resolved integer value, with type coercion if needed
Sourcepub fn get_f64(&self, path: &str) -> Result<f64>
pub fn get_f64(&self, path: &str) -> Result<f64>
Get a resolved float value, with type coercion if needed
Sourcepub fn get_bool(&self, path: &str) -> Result<bool>
pub fn get_bool(&self, path: &str) -> Result<bool>
Get a resolved boolean value, with strict coercion per ADR-012
Sourcepub fn resolve_all(&self) -> Result<()>
pub fn resolve_all(&self) -> Result<()>
Resolve all values in the configuration eagerly
Sourcepub fn to_value_raw(&self) -> Value
pub fn to_value_raw(&self) -> Value
Export the raw (unresolved) configuration as a Value
This shows the configuration with interpolation placeholders (${…})
Sourcepub fn to_value_redacted(&self, redact: bool) -> Result<Value>
pub fn to_value_redacted(&self, redact: bool) -> Result<Value>
Export the resolved configuration with optional redaction
When redact=true, sensitive values are replaced with “[REDACTED]”
Sourcepub fn to_yaml(&self) -> Result<String>
pub fn to_yaml(&self) -> Result<String>
Export the configuration as YAML
By default, resolves all values. Use to_yaml_raw() for unresolved output.
Sourcepub fn to_yaml_raw(&self) -> Result<String>
pub fn to_yaml_raw(&self) -> Result<String>
Export the raw (unresolved) configuration as YAML
Shows interpolation placeholders (${…}) without resolution.
Sourcepub fn to_yaml_redacted(&self, redact: bool) -> Result<String>
pub fn to_yaml_redacted(&self, redact: bool) -> Result<String>
Export the resolved configuration as YAML with optional redaction
When redact=true, sensitive values are replaced with “[REDACTED]”
Sourcepub fn to_json(&self) -> Result<String>
pub fn to_json(&self) -> Result<String>
Export the configuration as JSON
By default, resolves all values. Use to_json_raw() for unresolved output.
Sourcepub fn to_json_raw(&self) -> Result<String>
pub fn to_json_raw(&self) -> Result<String>
Export the raw (unresolved) configuration as JSON
Shows interpolation placeholders (${…}) without resolution.
Sourcepub fn to_json_redacted(&self, redact: bool) -> Result<String>
pub fn to_json_redacted(&self, redact: bool) -> Result<String>
Export the resolved configuration as JSON with optional redaction
When redact=true, sensitive values are replaced with “[REDACTED]”
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the resolution cache
Sourcepub fn register_resolver(&mut self, resolver: Arc<dyn Resolver>)
pub fn register_resolver(&mut self, resolver: Arc<dyn Resolver>)
Register a custom resolver
Sourcepub fn validate_raw(&self, schema: &Schema) -> Result<()>
pub fn validate_raw(&self, schema: &Schema) -> Result<()>
Validate the raw (unresolved) configuration against a schema
This performs structural validation (Phase 1 per ADR-007):
- Required keys are present
- Object/array structure matches
- Interpolations (${…}) are allowed as placeholders
Sourcepub fn validate(&self, schema: &Schema) -> Result<()>
pub fn validate(&self, schema: &Schema) -> Result<()>
Validate the resolved configuration against a schema
This performs type/value validation (Phase 2 per ADR-007):
- Resolved values match expected types
- Constraints (min, max, pattern, enum) are checked
Sourcepub fn validate_collect(&self, schema: &Schema) -> Vec<ValidationError>
pub fn validate_collect(&self, schema: &Schema) -> Vec<ValidationError>
Validate and collect all errors (instead of failing on first)