Skip to main content

Keeper

Trait Keeper 

Source
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§

Source

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.

Source

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.

Source

fn recall(&self, keys: &[&Key]) -> Result<Vec<Option<Kept>>, KeeperError>

What is kept under each of these, in the order they were asked. In batch form from the first day: against a remote store, one question per item is one round trip per item.

Source

fn keep( &self, key: &Key, value: &Value, meta: &[(&str, &str)], ) -> Result<(), KeeperError>

Keeps this, with what should be remembered beside it — the fingerprint of the code that produced it, above all, which is not in the key and is what a hit gets compared against.

Provided Methods§

Source

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.

Implementors§

Source§

impl Keeper for Packing<'_>