pub trait ConfigurationBinder {
    // Required methods
    fn reify<T: DeserializeOwned>(&self) -> T;
    fn bind<T: DeserializeOwned>(&self, instance: &mut T);
    fn bind_at<T: DeserializeOwned>(
        &self,
        key: impl AsRef<str>,
        instance: &mut T
    );
    fn get_value<T: FromStr>(
        &self,
        key: impl AsRef<str>
    ) -> Result<Option<T>, T::Err>;
    fn get_value_or_default<T: FromStr + Default>(
        &self,
        key: impl AsRef<str>
    ) -> Result<T, T::Err>;
}
Available on crate feature binder only.
Expand description

Provides binder extension methods for a Configuration.

Required Methods§

source

fn reify<T: DeserializeOwned>(&self) -> T

Creates and returns a structure bound to the configuration.

source

fn bind<T: DeserializeOwned>(&self, instance: &mut T)

Binds the configuration to the specified instance.

Arguments
  • instance - The instance to bind the configuration to
source

fn bind_at<T: DeserializeOwned>(&self, key: impl AsRef<str>, instance: &mut T)

Binds the specified configuration section to the provided instance.

Arguments
  • key - The key of the configuration section to bind
  • instance - The instance to bind the configuration to
source

fn get_value<T: FromStr>( &self, key: impl AsRef<str> ) -> Result<Option<T>, T::Err>

Gets a typed value from the configuration.

Arguments
  • key - The key of the value to retrieve
source

fn get_value_or_default<T: FromStr + Default>( &self, key: impl AsRef<str> ) -> Result<T, T::Err>

Gets an optional, typed value from the configuration.

Arguments
  • key - The key of the value to retrieve

Object Safety§

This trait is not object safe.

Implementors§