ConfigResolver

Struct ConfigResolver 

Source
pub struct ConfigResolver<Key, ConfigValue> { /* private fields */ }
Expand description

Structured configuration holding overrides with default values.

Implementations§

Source§

impl<Key, ConfigValue> ConfigResolver<Key, ConfigValue>

Source

pub fn new(base: ConfigValue, overrides: HashMap<Key, ConfigValue>) -> Self

Create a new instance of [Config].

Source

pub fn get<Q, F, Out>(&self, key: &Q, field: F) -> Out
where Key: Borrow<Q> + Eq + Hash, Q: Hash + Eq + ?Sized, F: FnOnce(&ConfigValue) -> Out,

Returns an always-existing field for the given key. Note field is FnOnce so it can be arbitrary function as long as it makes sense.

Source

pub fn get_opt<Q, F, Out>(&self, key: &Q, field: F) -> Option<Out>
where Key: Borrow<Q> + Eq + Hash, Q: Hash + Eq + ?Sized, F: FnMut(&ConfigValue) -> Option<Out>,

Returns an optional field for the given key. Note field as FnMut returning any type of Option.

Trait Implementations§

Source§

impl<Key: Debug, ConfigValue: Debug> Debug for ConfigResolver<Key, ConfigValue>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Key: Default, ConfigValue: Default> Default for ConfigResolver<Key, ConfigValue>

Source§

fn default() -> ConfigResolver<Key, ConfigValue>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Key, ConfigValue> Freeze for ConfigResolver<Key, ConfigValue>
where ConfigValue: Freeze,

§

impl<Key, ConfigValue> RefUnwindSafe for ConfigResolver<Key, ConfigValue>
where ConfigValue: RefUnwindSafe, Key: RefUnwindSafe,

§

impl<Key, ConfigValue> Send for ConfigResolver<Key, ConfigValue>
where ConfigValue: Send, Key: Send,

§

impl<Key, ConfigValue> Sync for ConfigResolver<Key, ConfigValue>
where ConfigValue: Sync, Key: Sync,

§

impl<Key, ConfigValue> Unpin for ConfigResolver<Key, ConfigValue>
where ConfigValue: Unpin, Key: Unpin,

§

impl<Key, ConfigValue> UnwindSafe for ConfigResolver<Key, ConfigValue>
where ConfigValue: UnwindSafe, Key: UnwindSafe,

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, 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, 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.