pub trait StorageFor<C: OutputType> {
// Required methods
fn get_cell_for_computation(&self, key: &C) -> Option<Cell>;
fn insert_new_cell(&mut self, cell: Cell, key: C);
fn get_input(&self, cell: Cell) -> &C;
fn get_output(&self, cell: Cell) -> Option<&C::Output>;
fn update_output(&mut self, cell: Cell, new_value: C::Output) -> bool;
}Expand description
This trait is implemented by a type storing a single computation type C.
Examples include HashMapStorage<C>, SingletonStorage<C>, and BTreeMapStorage<C>.
To implement this efficiently, most types implementing this are two-way maps
from C to Cell and from Cell to (C, Option<C::Output>).
Required Methods§
Sourcefn get_cell_for_computation(&self, key: &C) -> Option<Cell>
fn get_cell_for_computation(&self, key: &C) -> Option<Cell>
Given a computation key, return the cell associated with it, if it exists.
Sourcefn insert_new_cell(&mut self, cell: Cell, key: C)
fn insert_new_cell(&mut self, cell: Cell, key: C)
Insert a new Cell with the given computation that has yet to be run
Sourcefn get_input(&self, cell: Cell) -> &C
fn get_input(&self, cell: Cell) -> &C
Retrieve the input for this computation. The input is expected to already be inserted into this storage.
Sourcefn get_output(&self, cell: Cell) -> Option<&C::Output>
fn get_output(&self, cell: Cell) -> Option<&C::Output>
Retrieve the output for the given cell, if it exists
Sourcefn update_output(&mut self, cell: Cell, new_value: C::Output) -> bool
fn update_output(&mut self, cell: Cell, new_value: C::Output) -> bool
C has been re-run and has returned the output new_value, return true
if new_value has changed from its previous value, and cache the new value
if needed.