pub trait Storage: Sized {
// Required methods
fn output_is_unset(&self, cell: Cell, computation_id: u32) -> bool;
fn run_computation(
db: &DbHandle<'_, Self>,
cell: Cell,
computation_id: u32,
) -> bool;
fn gc(&mut self, used_cells: &HashSet<Cell>);
fn input_debug_string(&self, cell: Cell) -> String;
}Expand description
The Storage trait is implemented on a type which can cache all of the computations
used in the program (or a subset of it). These types are typically composed of
several fields with each field implementing StorageFor<T> where T is one
computation type. Note that each computation type must be unique within a Storage type.
This trait is most often automatically implemented by impl_storage!, see the documentation
on that macro for usage details.
Note that during serialization, the entire Storage is serialized along with the Db object.
To achieve backwards-compatible serialization even when new fields for new computation types
are added, it is recommended to use #[serde(default)] on any newly-added fields to still
be able to deserialize from older versions without that field.
Required Methods§
Sourcefn output_is_unset(&self, cell: Cell, computation_id: u32) -> bool
fn output_is_unset(&self, cell: Cell, computation_id: u32) -> bool
For the computation type with the given computation id, return true if the output with the given Cell has not yet been set.
Sourcefn run_computation(
db: &DbHandle<'_, Self>,
cell: Cell,
computation_id: u32,
) -> bool
fn run_computation( db: &DbHandle<'_, Self>, cell: Cell, computation_id: u32, ) -> bool
For the computation type with the given computation id, run the computation with the corresponding Cell, returning true if the result changed from its previous value.
Sourcefn gc(&mut self, used_cells: &HashSet<Cell>)
fn gc(&mut self, used_cells: &HashSet<Cell>)
Shrink the storage by removing any data not in use by the given cells
Sourcefn input_debug_string(&self, cell: Cell) -> String
fn input_debug_string(&self, cell: Cell) -> String
Return a Debug String representation of the Computation referred to by the given cell.
Used by inc-complete to label components of a cycle when a cycle is detected.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.