pub struct Cache(/* private fields */);Expand description
Used in order to cache things
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn load<C: Decode<()> + Default + 'static>(
&self,
path: impl AsRef<Path>,
) -> Result<C, Text>
pub fn load<C: Decode<()> + Default + 'static>( &self, path: impl AsRef<Path>, ) -> Result<C, Text>
Tries to load the cache stored by Duat for the given type
The cache must have been previously stored by
Cache::store. If it does not exist, or the buffer can’t
be correctly interpreted, returns None
Sourcepub fn store<C: Encode + 'static>(
&self,
path: impl AsRef<Path>,
cache: C,
) -> Result<usize, Text>
pub fn store<C: Encode + 'static>( &self, path: impl AsRef<Path>, cache: C, ) -> Result<usize, Text>
Stores the cache for the given type for that buffer
The cache will be stored under
$cache/duat/{base64_path}:{file_name}/{crate}::{type}.
The cache can then later be loaded by Cache::load.
Sourcepub fn delete(&self, path: impl Into<PathBuf>)
pub fn delete(&self, path: impl Into<PathBuf>)
Deletes the cache for all types for path
This is done if the buffer no longer exists, in order to prevent incorrect storage.
Sourcepub fn delete_for<C: 'static>(&self, path: impl AsRef<Path>)
pub fn delete_for<C: 'static>(&self, path: impl AsRef<Path>)
Deletes the cache for everything related to the given path
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.