pub struct Storage {
    pub footprint: Footprint,
    pub mode: FootprintMode,
    pub map: StorageMap,
}
Expand description

A special-purpose map from LedgerKeys to LedgerEntrys. Represents a transactional batch of contract IO from and to durable storage, while partitioning that IO between concurrently executing groups of contracts through the use of IO Footprints.

Specifically: access to each LedgerKey is mediated by the Footprint, which may be in either FootprintMode::Recording or FootprintMode::Enforcing mode.

FootprintMode::Recording mode is used to calculate Footprints during “preflight” execution of a contract. Once calculated, a recorded Footprint can be provided to “real” execution, which always runs in FootprintMode::Enforcing mode and enforces partitioned access.

Fields§

§footprint: Footprint§mode: FootprintMode§map: StorageMap

Implementations§

Constructs a new Storage in FootprintMode::Enforcing using a given Footprint and a storage map populated with all the keys listed in the Footprint.

Constructs a new Storage in FootprintMode::Recording using a given SnapshotSource.

Attempts to retrieve the LedgerEntry associated with a given LedgerKey in the Storage, returning an error if the key is not found.

In FootprintMode::Recording mode, records the read LedgerKey in the Footprint as AccessType::ReadOnly (unless already recorded as AccessType::ReadWrite) and reads through to the underlying SnapshotSource, if the LedgerKey has not yet been loaded.

In FootprintMode::Enforcing mode, succeeds only if the read LedgerKey has been declared in the Footprint.

Attempts to write to the LedgerEntry associated with a given LedgerKey in the Storage.

In FootprintMode::Recording mode, records the written LedgerKey in the Footprint as AccessType::ReadWrite.

In FootprintMode::Enforcing mode, succeeds only if the written LedgerKey has been declared in the Footprint as AccessType::ReadWrite.

Attempts to delete the LedgerEntry associated with a given LedgerKey in the Storage.

In FootprintMode::Recording mode, records the deleted LedgerKey in the Footprint as AccessType::ReadWrite.

In FootprintMode::Enforcing mode, succeeds only if the deleted LedgerKey has been declared in the Footprint as AccessType::ReadWrite.

Attempts to determine the presence of a LedgerEntry associated with a given LedgerKey in the Storage, returning Ok(true) if an entry with the key exists and Ok(false) if it does not.

In FootprintMode::Recording mode, records the access and reads-through to the underlying SnapshotSource.

In FootprintMode::Enforcing mode, succeeds only if the access has been declared in the Footprint.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more

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
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.