notesy::store

What a plugin keeps between runs: counts, caches, what it last synced. It's the plugin's own, private to it, and needs no permission.

rustuse notesy::store;

pub fn ready() {
    let saves = store::get("saves").unwrap_or(0);
    store::set("saves", saves + 1);
    store::set("last", #{ note: "Daily/today.md", at: 1757700000 });
    store::remove("last");
}
Function What it does
store::get(key) What it kept under key: Some(value), or None.
store::set(key, value) Keeps value under key, and writes the store.
store::remove(key) Forgets what it kept under key.

#What can be kept

true and false, integers, floats, strings, and vectors and objects of those. Anything else (a function, a struct of the script's own) is an error: a Function can't be kept.

Keys are the plugin's to choose. The whole store holds at most 1 MiB; a set that would pass that is an error, and the store stays as it was.

#Where it lives

plugin-data/<id>/store.toml in notesy's config folder, beside (not inside) the plugin's folder, so an update keeps it. The same file holds the values of its settings (notesy::settings), which the settings page writes; store::set reads the file again before writing it, so what the user set there is never lost.

If the file can't be read (it was edited by hand, say), the plugin doesn't start rather than write over it.

Every page