pub struct StackedConfig { /* private fields */ }
Expand description
Stack of configuration layers which can be merged as needed.
Implementations§
Source§impl StackedConfig
impl StackedConfig
Sourcepub fn load_file(
&mut self,
source: ConfigSource,
path: impl Into<PathBuf>,
) -> Result<(), ConfigError>
pub fn load_file( &mut self, source: ConfigSource, path: impl Into<PathBuf>, ) -> Result<(), ConfigError>
Loads config file from the specified path
, inserts it at the position
specified by source
. The file should exist.
Sourcepub fn load_dir(
&mut self,
source: ConfigSource,
path: impl AsRef<Path>,
) -> Result<(), ConfigError>
pub fn load_dir( &mut self, source: ConfigSource, path: impl AsRef<Path>, ) -> Result<(), ConfigError>
Loads config files from the specified directory path
, inserts them at
the position specified by source
. The directory should exist.
Sourcepub fn add_layer(&mut self, layer: ConfigLayer)
pub fn add_layer(&mut self, layer: ConfigLayer)
Inserts new layer at the position specified by layer.source
.
Sourcepub fn remove_layers(&mut self, source: ConfigSource)
pub fn remove_layers(&mut self, source: ConfigSource)
Removes layers of the specified source
.
Sourcepub fn layers(&self) -> &[ConfigLayer]
pub fn layers(&self) -> &[ConfigLayer]
Layers sorted by precedence.
Sourcepub fn get<'de, T: Deserialize<'de>>(
&self,
name: impl ToConfigNamePath,
) -> Result<T, ConfigError>
pub fn get<'de, T: Deserialize<'de>>( &self, name: impl ToConfigNamePath, ) -> Result<T, ConfigError>
Looks up value of the specified type T
from all layers, merges sub
fields as needed.
Sourcepub fn get_value(
&self,
name: impl ToConfigNamePath,
) -> Result<ConfigValue, ConfigError>
pub fn get_value( &self, name: impl ToConfigNamePath, ) -> Result<ConfigValue, ConfigError>
Looks up value from all layers, merges sub fields as needed.
Sourcepub fn get_table(
&self,
name: impl ToConfigNamePath,
) -> Result<ConfigTable, ConfigError>
pub fn get_table( &self, name: impl ToConfigNamePath, ) -> Result<ConfigTable, ConfigError>
Looks up sub table from all layers, merges fields as needed.
Trait Implementations§
Source§impl Clone for StackedConfig
impl Clone for StackedConfig
Source§fn clone(&self) -> StackedConfig
fn clone(&self) -> StackedConfig
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for StackedConfig
impl !RefUnwindSafe for StackedConfig
impl Send for StackedConfig
impl Sync for StackedConfig
impl Unpin for StackedConfig
impl !UnwindSafe for StackedConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more