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 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
This requires an exclusive reference to self to ensure that there are no currently running queries. Updating an input while an incremental computation is occurring can break soundness for dependency tracking.
Panics if the given computation is not an input - ie. panics if it has at least 1 dependency.
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 computation is stale and needs to be re-computed. Computations which have never been computed are also considered stale.
Note that this may re-compute dependencies of the given computation.
Sourcepub fn get<C: OutputType + ComputationId>(&self, compute: C) -> C::Outputwhere
S: StorageFor<C>,
pub fn get<C: OutputType + ComputationId>(&self, compute: C) -> C::Outputwhere
S: StorageFor<C>,
Async version of Db::get
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.