pub struct FileBackedValue<T>where
T: Serialize + DeserializeOwned,{ /* private fields */ }Implementations§
Source§impl<T> FileBackedValue<T>where
T: Serialize + DeserializeOwned,
impl<T> FileBackedValue<T>where
T: Serialize + DeserializeOwned,
pub fn new(filename: &str) -> Self
pub fn new_at(filename: &str, dir: &Path) -> Self
Sourcepub fn clear(&mut self) -> Result<()>
pub fn clear(&mut self) -> Result<()>
Clear the currently stored value and remove the backing file.
Sourcepub fn set_dirty_time(&mut self, dirty_time: Duration)
pub fn set_dirty_time(&mut self, dirty_time: Duration)
If the time since the file was last edited is longer ago than dirty_time,
require a recomputation of the value and a writeback to the file.
If this value is not set, the file is only ever read once.
Sourcepub fn set_dirty(&mut self) -> Option<T>
pub fn set_dirty(&mut self) -> Option<T>
Make this file dirty, requiring a recomputation the next time a value is get. Returns the currently stored value, if any.
Sourcepub fn get(&mut self) -> FileBackedValueResult<Option<&T>>
pub fn get(&mut self) -> FileBackedValueResult<Option<&T>>
Get the current value, which might be None if the backing file does not yet exist.
pub fn get_or_insert(&mut self, default: T) -> FileBackedValueResult<&T>
pub fn get_or_insert_with<F>(&mut self, default: F) -> FileBackedValueResult<&T>where
F: FnOnce() -> T,
Auto Trait Implementations§
impl<T> Freeze for FileBackedValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for FileBackedValue<T>where
T: RefUnwindSafe,
impl<T> Send for FileBackedValue<T>where
T: Send,
impl<T> Sync for FileBackedValue<T>where
T: Sync,
impl<T> Unpin for FileBackedValue<T>where
T: Unpin,
impl<T> UnwindSafe for FileBackedValue<T>where
T: UnwindSafe,
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