pub struct SettingsStore { /* private fields */ }Expand description
Handles persistence of Settings to disk.
By default, uses ~/.config/tinyharness/settings.json. This can be
overridden with SettingsStore::new for testing or alternative paths.
Implementations§
Source§impl SettingsStore
impl SettingsStore
Sourcepub fn default_path() -> Self
pub fn default_path() -> Self
Create a store that reads/writes from the default path
(~/.config/tinyharness/settings.json).
Sourcepub fn load(&self) -> Result<Settings, SettingsError>
pub fn load(&self) -> Result<Settings, SettingsError>
Load settings from disk.
Returns Ok(Settings) with defaults if the file doesn’t exist,
or an error if the file exists but cannot be parsed.
Sourcepub fn load_or_default(&self) -> Settings
pub fn load_or_default(&self) -> Settings
Load settings from disk, returning defaults on any error.
This matches the original behaviour and is suitable for application startup where you don’t want to fail on corrupt settings files.
Auto Trait Implementations§
impl Freeze for SettingsStore
impl RefUnwindSafe for SettingsStore
impl Send for SettingsStore
impl Sync for SettingsStore
impl Unpin for SettingsStore
impl UnsafeUnpin for SettingsStore
impl UnwindSafe for SettingsStore
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