Skip to main content

ConfigResolver

Struct ConfigResolver 

Source
pub struct ConfigResolver {
    pub cli_flags: HashMap<String, Option<String>>,
    pub config_file: Option<HashMap<String, String>>,
    pub defaults: HashMap<&'static str, &'static str>,
    /* private fields */
}
Expand description

Resolved configuration following 4-tier precedence:

  1. CLI flags — highest priority
  2. Environment variables
  3. Config file (YAML, dot-flattened keys)
  4. Built-in defaults — lowest priority

Fields§

§cli_flags: HashMap<String, Option<String>>

CLI flags map (flag name → value or None if not provided).

§config_file: Option<HashMap<String, String>>

Flattened key → value map loaded from the config file. None if the file was not found or could not be parsed.

§defaults: HashMap<&'static str, &'static str>

Built-in default values.

Implementations§

Source§

impl ConfigResolver

Source

pub const DEFAULTS: &'static [(&'static str, &'static str)]

Default configuration values.

Source

pub fn new( cli_flags: Option<HashMap<String, Option<String>>>, config_path: Option<PathBuf>, ) -> Self

Create a new ConfigResolver.

§Arguments
  • cli_flags — CLI flag overrides (e.g. --extensions-dir → /path)
  • config_path — Optional explicit path to apcore.yaml
Source

pub fn resolve( &self, key: &str, cli_flag: Option<&str>, env_var: Option<&str>, ) -> Option<String>

Resolve a configuration value using 4-tier precedence.

§Arguments
  • key — dot-separated config key (e.g. "extensions.root")
  • cli_flag — optional CLI flag name to check in _cli_flags
  • env_var — optional environment variable name

Returns None when the key is not present in any tier.

Source

pub fn flatten_dict(&self, map: Value) -> HashMap<String, String>

Recursively flatten a nested JSON map into dot-separated keys.

Example: {"extensions": {"root": "/path"}}{"extensions.root": "/path"}

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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