Trait config::ext::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§
sourcefn reify<T: DeserializeOwned>(&self) -> T
fn reify<T: DeserializeOwned>(&self) -> T
Creates and returns a structure bound to the configuration.
sourcefn bind<T: DeserializeOwned>(&self, instance: &mut T)
fn bind<T: DeserializeOwned>(&self, instance: &mut T)
Binds the configuration to the specified instance.
Arguments
instance
- The instance to bind the configuration to
sourcefn bind_at<T: DeserializeOwned>(&self, key: impl AsRef<str>, instance: &mut T)
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 bindinstance
- The instance to bind the configuration to
Object Safety§
This trait is not object safe.