pub struct FileJsonCache { /* private fields */ }Implementations§
Source§impl FileJsonCache
impl FileJsonCache
pub fn new(dir: impl Into<PathBuf>, ttl: Duration) -> Self
pub fn ttl(&self) -> Duration
pub fn dir(&self) -> &Path
pub fn ensure_dir(&self) -> Result<()>
pub fn path_for(&self, key: &str) -> PathBuf
Sourcepub fn get<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn get<T: DeserializeOwned>(&self, key: &str) -> Option<T>
Read cached value when within TTL. Expired entries are removed.
Trait Implementations§
Source§impl Clone for FileJsonCache
impl Clone for FileJsonCache
Source§fn clone(&self) -> FileJsonCache
fn clone(&self) -> FileJsonCache
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 FileJsonCache
impl RefUnwindSafe for FileJsonCache
impl Send for FileJsonCache
impl Sync for FileJsonCache
impl Unpin for FileJsonCache
impl UnsafeUnpin for FileJsonCache
impl UnwindSafe for FileJsonCache
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