pub struct FileBackedValue { /* private fields */ }Implementations§
Source§impl FileBackedValue
impl FileBackedValue
Sourcepub fn new(filename: &str) -> Self
pub fn new(filename: &str) -> Self
Create a file-backed value in the user’s data directory.
§Example
- Linux:
/home/alice/.local/share - MacOS:
/Users/Alice/Library/Application Support - Windows:
C:\Users\Alice\AppData\Roaming
Sourcepub fn new_at(filename: &str, parent: &Path) -> Self
pub fn new_at(filename: &str, parent: &Path) -> Self
Create a file-backed value in the specified directory.
Sourcepub fn set_dirty_time(&mut self, dirty_time: Duration)
pub fn set_dirty_time(&mut self, dirty_time: Duration)
Set the duration after which the file is considered dirty and needs to be recomputed.
Sourcepub fn clear(&mut self) -> Result<()>
pub fn clear(&mut self) -> Result<()>
Clear the currently stored value and remove the backing file.
Sourcepub fn get<T>(&mut self) -> FileBackedValueResult<Option<T>>where
T: DeserializeOwned,
pub fn get<T>(&mut self) -> FileBackedValueResult<Option<T>>where
T: DeserializeOwned,
Get the current value, which might be None if the backing file does not yet exist.
Sourcepub fn get_or_insert<T>(&mut self, default: T) -> FileBackedValueResult<T>where
T: DeserializeOwned + Serialize,
pub fn get_or_insert<T>(&mut self, default: T) -> FileBackedValueResult<T>where
T: DeserializeOwned + Serialize,
Get the current value, or insert default if the backing file does not exist or is dirty.
Sourcepub fn get_or_insert_with<F, T>(
&mut self,
default: F,
) -> FileBackedValueResult<T>
pub fn get_or_insert_with<F, T>( &mut self, default: F, ) -> FileBackedValueResult<T>
Get the current value, or insert default() if the backing file does not exist or is dirty.
Trait Implementations§
Source§impl Clone for FileBackedValue
impl Clone for FileBackedValue
Source§fn clone(&self) -> FileBackedValue
fn clone(&self) -> FileBackedValue
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 moreAuto Trait Implementations§
impl Freeze for FileBackedValue
impl RefUnwindSafe for FileBackedValue
impl Send for FileBackedValue
impl Sync for FileBackedValue
impl Unpin for FileBackedValue
impl UnsafeUnpin for FileBackedValue
impl UnwindSafe for FileBackedValue
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