pub trait Keeper: Send + Sync {
// Required methods
fn key_of(&self, value: &Value) -> Option<Key>;
fn combine(&self, parts: &[&str]) -> Key;
fn recall(&self, keys: &[&Key]) -> Result<Vec<Option<Kept>>, KeeperError>;
fn keep(
&self,
key: &Key,
value: &Value,
meta: &[(&str, &str)],
) -> Result<(), KeeperError>;
// Provided method
fn present(&self, keys: &[&Key]) -> Result<Vec<bool>, KeeperError> { ... }
}Expand description
Hashes recipes and keeps what they name.
Required Methods§
Sourcefn key_of(&self, value: &Value) -> Option<Key>
fn key_of(&self, value: &Value) -> Option<Key>
The key of a value by its content, which only a root needs: from
there down, keys come from keys. None if the value cannot leave this
process, which is not a failure — nothing below it is cached either.
Sourcefn combine(&self, parts: &[&str]) -> Key
fn combine(&self, parts: &[&str]) -> Key
One key out of the ingredients of a recipe, in the order given. The
parts have to stay apart: run together, ["ab", "c"] and
["a", "bc"] would name the same thing.
Provided Methods§
Sourcefn present(&self, keys: &[&Key]) -> Result<Vec<bool>, KeeperError>
fn present(&self, keys: &[&Key]) -> Result<Vec<bool>, KeeperError>
Whether each of these is kept, without reading any of it.
A key is knowable before anything runs, so the engine can ask which answers it already has and then not execute what only fed one of them. The default is honest and expensive — it reads them; whoever can answer by name alone should say so, or asking early costs what it saves.