Config

Struct Config 

Source
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

Source

pub fn new(value: Value) -> Self

Create a new Config from a Value

Source

pub fn with_options(value: Value, options: ConfigOptions) -> Self

Create a Config with custom options

Source

pub fn with_resolvers(value: Value, resolvers: ResolverRegistry) -> Self

Create a Config with a custom resolver registry

Source

pub fn from_yaml(yaml: &str) -> Result<Self>

Load configuration from a YAML string

Source

pub fn from_yaml_with_options( yaml: &str, options: ConfigOptions, ) -> Result<Self>

Load configuration from a YAML string with options

Source

pub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self>

Load configuration from a YAML file

Source

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
Source

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.

Source

pub fn from_json(json: &str) -> Result<Self>

Load configuration from a JSON string

Source

pub fn get_raw(&self, path: &str) -> Result<&Value>

Get the raw (unresolved) value at a path

Source

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.

Source

pub fn get_string(&self, path: &str) -> Result<String>

Get a resolved string value, with type coercion if needed

Source

pub fn get_i64(&self, path: &str) -> Result<i64>

Get a resolved integer value, with type coercion if needed

Source

pub fn get_f64(&self, path: &str) -> Result<f64>

Get a resolved float value, with type coercion if needed

Source

pub fn get_bool(&self, path: &str) -> Result<bool>

Get a resolved boolean value, with strict coercion per ADR-012

Source

pub fn resolve_all(&self) -> Result<()>

Resolve all values in the configuration eagerly

Source

pub fn to_value(&self) -> Result<Value>

Export the configuration as a resolved Value

Source

pub fn to_value_raw(&self) -> Value

Export the raw (unresolved) configuration as a Value

This shows the configuration with interpolation placeholders (${…})

Source

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]”

Source

pub fn to_yaml(&self) -> Result<String>

Export the configuration as YAML

By default, resolves all values. Use to_yaml_raw() for unresolved output.

Source

pub fn to_yaml_raw(&self) -> Result<String>

Export the raw (unresolved) configuration as YAML

Shows interpolation placeholders (${…}) without resolution.

Source

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]”

Source

pub fn to_json(&self) -> Result<String>

Export the configuration as JSON

By default, resolves all values. Use to_json_raw() for unresolved output.

Source

pub fn to_json_raw(&self) -> Result<String>

Export the raw (unresolved) configuration as JSON

Shows interpolation placeholders (${…}) without resolution.

Source

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]”

Source

pub fn clear_cache(&self)

Clear the resolution cache

Source

pub fn register_resolver(&mut self, resolver: Arc<dyn Resolver>)

Register a custom resolver

Source

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
Source

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
Source

pub fn validate_collect(&self, schema: &Schema) -> Vec<ValidationError>

Validate and collect all errors (instead of failing on first)

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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 !UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more