pub struct Db<Storage> { /* private fields */ }Expand description
The central database object to manage and cache incremental computations.
To use this, a type implementing Storage is required to be provided.
See the documentation for impl_storage!.
Implementations§
Source§impl<S> Db<S>
impl<S> Db<S>
Sourcepub fn with_storage(storage: S) -> Self
pub fn with_storage(storage: S) -> Self
Construct a new Db object with the given initial storage.
Sourcepub fn storage_mut(&mut self) -> &mut S
pub fn storage_mut(&mut self) -> &mut S
Retrieve a mutable reference to this Db’s storage.
Note that any mutations made to the storage using this are not tracked by the Db!
Using this incorrectly may break correctness!
Source§impl<S: Storage> Db<S>
impl<S: Storage> Db<S>
Sourcepub fn is_stale<C: OutputType>(&self, input: &C) -> boolwhere
S: StorageFor<C>,
pub fn is_stale<C: OutputType>(&self, input: &C) -> boolwhere
S: StorageFor<C>,
True if a given input is stale and needs to be re-computed. Inputs which have never been computed are also considered stale.
This does not actually re-compute the input.
Sourcepub fn update_input<C>(&mut self, input: C, new_value: C::Output)
pub fn update_input<C>(&mut self, input: C, new_value: C::Output)
Updates an input with a new value
Panics in debug mode if the input is not an input - ie. it has at least 1 dependency. Note that this check is skipped when compiling in Release mode.
Sourcepub fn get<C: OutputType + ComputationId>(&mut self, compute: C) -> &C::Outputwhere
S: StorageFor<C>,
pub fn get<C: OutputType + ComputationId>(&mut self, compute: C) -> &C::Outputwhere
S: StorageFor<C>,
Retrieves the up to date value for the given computation, re-running any dependencies as necessary.
This function can panic if the dynamic type of the value returned by compute.run(..) is not T.