Trait ConfigurationBinder

Source
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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§