pub struct ConfigFile { /* private fields */ }
Expand description
Wrapper for file-based ConfigLayer
, providing convenient methods for
modification.
Implementations§
Source§impl ConfigFile
impl ConfigFile
Sourcepub fn load_or_empty(
source: ConfigSource,
path: impl Into<PathBuf>,
) -> Result<Self, ConfigLoadError>
pub fn load_or_empty( source: ConfigSource, path: impl Into<PathBuf>, ) -> Result<Self, ConfigLoadError>
Loads TOML file from the specified path
if exists. Returns an empty
object if the file doesn’t exist.
Sourcepub fn from_layer(layer: Arc<ConfigLayer>) -> Result<Self, Arc<ConfigLayer>>
pub fn from_layer(layer: Arc<ConfigLayer>) -> Result<Self, Arc<ConfigLayer>>
Wraps file-based ConfigLayer
for modification. Returns Err(layer)
if the source path
is unknown.
Sourcepub fn save(&self) -> Result<(), ConfigFileSaveError>
pub fn save(&self) -> Result<(), ConfigFileSaveError>
Writes serialized data to the source file.
Sourcepub fn layer(&self) -> &Arc<ConfigLayer>
pub fn layer(&self) -> &Arc<ConfigLayer>
Returns the underlying config layer.
Sourcepub fn set_value(
&mut self,
name: impl ToConfigNamePath,
new_value: impl Into<ConfigValue>,
) -> Result<Option<ConfigValue>, ConfigUpdateError>
pub fn set_value( &mut self, name: impl ToConfigNamePath, new_value: impl Into<ConfigValue>, ) -> Result<Option<ConfigValue>, ConfigUpdateError>
Sourcepub fn delete_value(
&mut self,
name: impl ToConfigNamePath,
) -> Result<Option<ConfigValue>, ConfigUpdateError>
pub fn delete_value( &mut self, name: impl ToConfigNamePath, ) -> Result<Option<ConfigValue>, ConfigUpdateError>
Trait Implementations§
Source§impl Clone for ConfigFile
impl Clone for ConfigFile
Source§fn clone(&self) -> ConfigFile
fn clone(&self) -> ConfigFile
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ConfigFile
impl RefUnwindSafe for ConfigFile
impl Send for ConfigFile
impl Sync for ConfigFile
impl Unpin for ConfigFile
impl UnwindSafe for ConfigFile
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