Skip to main content

DbHandle

Struct DbHandle 

Source
pub struct DbHandle<'db, S> { /* private fields */ }
Expand description

A handle to the database during some operation.

This wraps calls to the Db so that any get calls will be automatically registered as dependencies of the current operation.

Implementations§

Source§

impl<'db, S> DbHandle<'db, S>

Source

pub fn storage(&self) -> &S

Retrieve an immutable reference to this Db’s storage

Note that any mutations made to the storage using this are not tracked by the database! Using this incorrectly may break correctness!

Source§

impl<S: Storage> DbHandle<'_, S>

Source

pub fn get<C: Computation>(&self, compute: C) -> C::Output
where S: StorageFor<C>,

Locking behavior: This function locks the cell corresponding to the given computation. This can cause a deadlock if the computation recursively depends on itself.

Source

pub fn accumulate<Item>(&self, item: Item)
where S: Accumulate<Item>,

Accumulate an item in the current computation. This item can be retrieved along with all other accumulated items in this computation and its dependencies via a call to get_accumulated.

This is most often used for operations like pushing diagnostics or logs.

Trait Implementations§

Source§

impl<'db, S, C> DbGet<C> for DbHandle<'db, S>
where C: Computation, S: Storage + StorageFor<C>,

Source§

fn get(&self, key: C) -> C::Output

Run an incremental computation C and return its output. If C is already cached, no computation will be performed.

Auto Trait Implementations§

§

impl<'db, S> Freeze for DbHandle<'db, S>

§

impl<'db, S> !RefUnwindSafe for DbHandle<'db, S>

§

impl<'db, S> Send for DbHandle<'db, S>
where S: Sync,

§

impl<'db, S> Sync for DbHandle<'db, S>
where S: Sync,

§

impl<'db, S> Unpin for DbHandle<'db, S>

§

impl<'db, S> !UnwindSafe for DbHandle<'db, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.