Struct bdrck::configuration::Configuration
source · pub struct Configuration<T> { /* private fields */ }
Expand description
A Configuration represents a set of configuration values, initially loaded from disk, and which can be persisted back to disk e.g. just before the application exits. Generally it is expected that only one instance per Identifier is needed globally, and the other functions in this module are intended to provide an easy singleton interface for this class.
Implementations
sourceimpl<T: Clone + Serialize + DeserializeOwned> Configuration<T>
impl<T: Clone + Serialize + DeserializeOwned> Configuration<T>
sourcepub fn new(
id: Identifier,
default: T,
custom_path: Option<&Path>
) -> Result<Configuration<T>>
pub fn new(
id: Identifier,
default: T,
custom_path: Option<&Path>
) -> Result<Configuration<T>>
Initialize a new Configuration with the given identifier, default set of configuration values, and custom disk persistence path (optional). An error might occur if determining the persistence path to use fails, or if deserializing the previously persisted configuration (if any) fails.
sourcepub fn set(&mut self, config: T)
pub fn set(&mut self, config: T)
Replace all existing configuration values with the given entirely new set of configuration values.
Auto Trait Implementations
impl<T> RefUnwindSafe for Configuration<T>where
T: RefUnwindSafe,
impl<T> Send for Configuration<T>where
T: Send,
impl<T> Sync for Configuration<T>where
T: Sync,
impl<T> Unpin for Configuration<T>where
T: Unpin,
impl<T> UnwindSafe for Configuration<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more