Skip to main content

Module cache

Module cache 

Source
Expand description

Caching utilities for Duat

The cache in Duat is used when restoring previous information from a previous Duat instance, or when reloading Duat’s configuration crate.

One example for where this is used is the Ui, which has information about how much a given buffer should be scrolled when opening it in Duat. Another example is Selections, which stores a list of open Cursors, to start the buffer on.

Plugins are able to cache any type that implements Encode and Decode. Duat provides these traits from the bincode crate, but in order to derive them, you will need a small addition on the declaration of the type:

use duat_core::context::cache::{Decode, Encode};
#[derive(Encode, Decode)]
#[bincode(crate = "duat_core::context::cache::bincode")]
enum MyCacheableEnum {
    // ...
}

Re-exports§

pub use bincode;

Traits§

Decode
Trait that makes a type able to be decoded, akin to serde’s DeserializeOwned trait.
Encode
Any source that can be encoded. This trait should be implemented for all types that you want to be able to use with any of the encode_with methods.

Functions§

delete
Deletes the cache for all types for path
delete_for
Deletes the cache for everything related to the given path
load
Tries to load the cache stored by Duat for the given type
store
Stores the cache for the given type for that buffer

Derive Macros§

Decode
Encode