pub struct SnapshotItem<'a, T> { /* private fields */ }
Expand description

Item that maintains a snapshot of one or more checkpoints. We can query historical data as well as current state. What data is snapshotted depends on the Strategy.

Implementations

Example:

use cw_storage_plus::{SnapshotItem, Strategy};

SnapshotItem::<'static, u64>::new(
    "every",
    "every__check",
    "every__change",
    Strategy::EveryBlock);

load will return an error if no data is set, or on parse error

may_load will parse the data stored if present, returns Ok(None) if no data there. returns an error on parsing issues

Loads the data, perform the specified action, and store the result in the database. This is a shorthand for some common sequences, which may be useful.

If the data exists, action(Some(value)) is called. Otherwise action(None) is called.

This is a bit more customized than needed to only read “old” value 1 time, not 2 per naive approach

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.