pub struct Configuration { /* private fields */ }Expand description
Represents a configuration.
Implementations§
Source§impl Configuration
impl Configuration
Sourcepub fn new(
settings: Settings,
tokens: impl IntoIterator<Item = Box<dyn ChangeToken>>,
providers: Vec<String>,
) -> Self
pub fn new( settings: Settings, tokens: impl IntoIterator<Item = Box<dyn ChangeToken>>, providers: Vec<String>, ) -> Self
Initializes a new Configuration.
§Arguments
settings- The configuration settingstokens- The sequence of change tokens associated with the configurationproviders- The names of the providers that generated the configuration
Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Gets a configuration value.
§Arguments
key- The case-insensitive key of the configuration value to get
Sourcepub fn section(&self, key: impl Into<String>) -> Section<'_>
pub fn section(&self, key: impl Into<String>) -> Section<'_>
Gets a section in this configuration.
§Arguments
key- The case-insensitive key of the configuration subsection to get
Sourcepub fn change_token(&self) -> impl ChangeToken
pub fn change_token(&self) -> impl ChangeToken
Returns a change token that indicates when the configuration has changed.
Trait Implementations§
Source§impl Binder for Configuration
Available on crate feature binder only.
impl Binder for Configuration
Available on crate feature
binder only.Source§fn reify<T: DeserializeOwned>(&self) -> Result<T>
fn reify<T: DeserializeOwned>(&self) -> Result<T>
Creates and returns a structure reified from the configuration.
Source§fn bind<T: DeserializeOwned>(&self, instance: &mut T) -> Result
fn bind<T: DeserializeOwned>(&self, instance: &mut T) -> Result
Binds the configuration to the specified instance. Read more
Source§fn bind_at<T: DeserializeOwned>(
&self,
key: impl AsRef<str>,
instance: &mut T,
) -> Result
fn bind_at<T: DeserializeOwned>( &self, key: impl AsRef<str>, instance: &mut T, ) -> Result
Binds the specified configuration section to the provided instance. Read more
Source§fn get_value<T: FromStr>(
&self,
key: impl AsRef<str>,
) -> Result<Option<T>, T::Err>
fn get_value<T: FromStr>( &self, key: impl AsRef<str>, ) -> Result<Option<T>, T::Err>
Gets a typed value from the configuration. Read more
Source§fn get_value_or_default<T: FromStr + Default>(
&self,
key: impl AsRef<str>,
) -> Result<T, T::Err>
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. Read more
Source§fn reify_unchecked<T: DeserializeOwned>(&self) -> T
fn reify_unchecked<T: DeserializeOwned>(&self) -> T
Creates and returns a structure reified from the configuration. Read more
Source§fn bind_unchecked<T: DeserializeOwned>(&self, instance: &mut T)
fn bind_unchecked<T: DeserializeOwned>(&self, instance: &mut T)
Binds the configuration to the specified instance. Read more
Source§fn bind_at_unchecked<T: DeserializeOwned>(
&self,
key: impl AsRef<str>,
instance: &mut T,
)
fn bind_at_unchecked<T: DeserializeOwned>( &self, key: impl AsRef<str>, instance: &mut T, )
Binds the specified configuration section to the provided instance. Read more
Source§impl Clone for Configuration
impl Clone for Configuration
Source§fn clone(&self) -> Configuration
fn clone(&self) -> Configuration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Configuration
impl Debug for Configuration
Source§impl Display for Configuration
impl Display for Configuration
Source§impl<'a> From<&'a Configuration> for Vec<Section<'a>>
impl<'a> From<&'a Configuration> for Vec<Section<'a>>
Source§fn from(config: &'a Configuration) -> Self
fn from(config: &'a Configuration) -> Self
Converts to this type from the input type.
Source§impl<'a> IntoIterator for &'a Configuration
impl<'a> IntoIterator for &'a Configuration
Source§impl IntoIterator for Configuration
impl IntoIterator for Configuration
Source§impl Merge<Configuration> for Settings
impl Merge<Configuration> for Settings
Source§fn merge(&mut self, other: &Configuration)
fn merge(&mut self, other: &Configuration)
Merges an object into current object. Read more
Source§impl Merge<Settings> for Configuration
impl Merge<Settings> for Configuration
Source§impl Merge for Configuration
impl Merge for Configuration
Source§impl Reloadable for Configuration
impl Reloadable for Configuration
Source§fn can_reload(&self) -> bool
fn can_reload(&self) -> bool
Gets a value indicating whether the configuration can be reloaded.
Source§fn reload_token(&self) -> impl ChangeToken + 'static
fn reload_token(&self) -> impl ChangeToken + 'static
Gets a change token that will be notified when the configuration is reloaded.
Auto Trait Implementations§
impl Freeze for Configuration
impl !RefUnwindSafe for Configuration
impl Send for Configuration
impl Sync for Configuration
impl Unpin for Configuration
impl UnsafeUnpin for Configuration
impl !UnwindSafe for Configuration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more