pub async fn cache_res<D, F, Ft>(name: &str, f: F, force_run: bool) -> D where
    D: Serialize + for<'de> Deserialize<'de> + Any,
    F: Fn() -> Ft,
    Ft: Future<Output = D>, 
Expand description

Runs the given function once and then caches the result to the filesystem for future execution. Think of this as filesystem-level memoizing. In future, this will be broken out into its own crate and wrapped by Perseus. The second parameter to this allows forcing the function to re-fetch data every time, which is useful if you want to revalidate data or test your fetching logic again. Note that a change to the logic will not trigger a reload unless you make it do so. For this reason, it’s recommended to only use this wrapper once you’ve tested your fetching logic.

When running automated tests, you may wish to set force_run to the result of an environment variable check that you’ll use when testing.

This function expects to be run in the context of .perseus/, or any directory in which a folder cache/ is available. If you’re using Perseus without the CLI and you don’t want that directory to exist, you shouldn’t use this function.

Panics

If this filesystem operations fail, this function will panic. It can’t return a graceful error since it’s expected to return the type you requested.