Struct fuel_vm::prelude::MemoryStorage
source · [−]pub struct MemoryStorage { /* private fields */ }
Expand description
In-memory storage implementation for the interpreter.
It tracks 3 states:
- memory: the transactions will be applied to this state.
- transacted: will receive the committed
memory
state. - persisted: will receive the persisted
transacted
state.
Implementations
sourceimpl MemoryStorage
impl MemoryStorage
sourcepub fn contract_state(
&self,
contract: &ContractId,
key: &Bytes32
) -> Cow<'_, Bytes32>
pub fn contract_state(
&self,
contract: &ContractId,
key: &Bytes32
) -> Cow<'_, Bytes32>
Fetch a mapping from the contract state.
Trait Implementations
sourceimpl<'a> AsMut<MemoryStorage> for MemoryClient
impl<'a> AsMut<MemoryStorage> for MemoryClient
sourcefn as_mut(&mut self) -> &mut MemoryStorage
fn as_mut(&mut self) -> &mut MemoryStorage
Converts this type into a mutable reference of the (usually inferred) input type.
sourceimpl<'a> AsRef<MemoryStorage> for MemoryClient
impl<'a> AsRef<MemoryStorage> for MemoryClient
sourcefn as_ref(&self) -> &MemoryStorage
fn as_ref(&self) -> &MemoryStorage
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl Clone for MemoryStorage
impl Clone for MemoryStorage
sourcefn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for MemoryStorage
impl Debug for MemoryStorage
sourceimpl Default for MemoryStorage
impl Default for MemoryStorage
sourceimpl<'a> From<MemoryStorage> for MemoryClient
impl<'a> From<MemoryStorage> for MemoryClient
sourcefn from(s: MemoryStorage) -> Self
fn from(s: MemoryStorage) -> Self
Converts to this type from the input type.
sourceimpl InterpreterStorage for MemoryStorage
impl InterpreterStorage for MemoryStorage
type DataError = Infallible
type DataError = Infallible
Error implementation for reasons unspecified in the protocol.
sourcefn block_height(&self) -> Result<u32, Infallible>
fn block_height(&self) -> Result<u32, Infallible>
Provide the current block height in which the transactions should be
executed. Read more
sourcefn timestamp(&self, height: u32) -> Result<Word, Self::DataError>
fn timestamp(&self, height: u32) -> Result<Word, Self::DataError>
Return the timestamp of a given block Read more
sourcefn block_hash(&self, block_height: u32) -> Result<Bytes32, Infallible>
fn block_hash(&self, block_height: u32) -> Result<Bytes32, Infallible>
Provide the block hash from a given height.
sourcefn coinbase(&self) -> Result<Address, Infallible>
fn coinbase(&self) -> Result<Address, Infallible>
Provide the coinbase address for the VM instructions implementation.
sourcefn merkle_contract_state_range(
&self,
_id: &ContractId,
_start_key: &Bytes32,
_range: Word
) -> Result<Vec<Option<Cow<'_, Bytes32>>>, Self::DataError>
fn merkle_contract_state_range(
&self,
_id: &ContractId,
_start_key: &Bytes32,
_range: Word
) -> Result<Vec<Option<Cow<'_, Bytes32>>>, Self::DataError>
Fetch a range of values from a key-value mapping in a contract storage.
Returns the full range requested using optional values in case
a requested slot is unset. Read more
sourcefn merkle_contract_state_insert_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_values: &[Bytes32]
) -> Result<Option<()>, Self::DataError>
fn merkle_contract_state_insert_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_values: &[Bytes32]
) -> Result<Option<()>, Self::DataError>
Insert a range of key-value mappings into contract storage.
Returns None if any of the keys in the range were previously unset. Read more
sourcefn merkle_contract_state_remove_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_range: Word
) -> Result<Option<()>, Self::DataError>
fn merkle_contract_state_remove_range(
&mut self,
_contract: &ContractId,
_start_key: &Bytes32,
_range: Word
) -> Result<Option<()>, Self::DataError>
Remove a range of key-values from contract storage.
Returns None if any of the keys in the range were already unset. Read more
sourcefn deploy_contract(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract
) -> Result<(), Self::DataError>
fn deploy_contract(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract
) -> Result<(), Self::DataError>
Deploy a contract into the storage
sourcefn deploy_contract_with_id(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract,
root: &Bytes32,
id: &ContractId
) -> Result<(), Self::DataError>
fn deploy_contract_with_id(
&mut self,
salt: &Salt,
slots: &[StorageSlot],
contract: &Contract,
root: &Bytes32,
id: &ContractId
) -> Result<(), Self::DataError>
Deploy a contract into the storage with contract id
sourcefn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
fn storage_contract(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, Contract>>, Self::DataError>
Fetch a previously inserted contract code from the chain state for a
given contract. Read more
sourcefn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
fn storage_contract_insert(
&mut self,
id: &ContractId,
contract: &Contract
) -> Result<Option<Contract>, Self::DataError>
Append a contract to the chain, provided its identifier. Read more
sourcefn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
fn storage_contract_exists(
&self,
id: &ContractId
) -> Result<bool, Self::DataError>
Check if a provided contract exists in the chain.
sourcefn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
fn storage_contract_root(
&self,
id: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Self::DataError>
Fetch a previously inserted salt+root tuple from the chain state for a
given contract. Read more
sourcefn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
fn storage_contract_root_insert(
&mut self,
id: &ContractId,
salt: &Salt,
root: &Bytes32
) -> Result<Option<(Salt, Bytes32)>, Self::DataError>
Append the salt+root of a contract that was appended to the chain.
sourcefn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
fn merkle_contract_state(
&self,
id: &ContractId,
key: &Bytes32
) -> Result<Option<Cow<'_, Bytes32>>, Self::DataError>
Fetch the value form a key-value mapping in a contract storage.
sourcefn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
fn merkle_contract_state_insert(
&mut self,
contract: &ContractId,
key: &Bytes32,
value: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
Insert a key-value mapping in a contract storage.
sourcefn merkle_contract_state_remove(
&mut self,
contract: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
fn merkle_contract_state_remove(
&mut self,
contract: &ContractId,
key: &Bytes32
) -> Result<Option<Bytes32>, Self::DataError>
Remove a key-value mapping from a contract storage.
sourcefn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<Word>, Self::DataError>
fn merkle_contract_asset_id_balance(
&self,
id: &ContractId,
asset_id: &AssetId
) -> Result<Option<Word>, Self::DataError>
Fetch the balance of an asset ID in a contract storage.
sourcefn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: Word
) -> Result<Option<Word>, Self::DataError>
fn merkle_contract_asset_id_balance_insert(
&mut self,
contract: &ContractId,
asset_id: &AssetId,
value: Word
) -> Result<Option<Word>, Self::DataError>
Update the balance of an asset ID in a contract storage.
sourceimpl MerkleRootStorage<ContractId, ContractsAssets<'_>> for MemoryStorage
impl MerkleRootStorage<ContractId, ContractsAssets<'_>> for MemoryStorage
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the stored
Type
in the storage. Read moresourceimpl MerkleRootStorage<ContractId, ContractsState<'_>> for MemoryStorage
impl MerkleRootStorage<ContractId, ContractsState<'_>> for MemoryStorage
sourcefn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
fn root(&mut self, parent: &ContractId) -> Result<MerkleRoot, Infallible>
Return the merkle root of the stored
Type
in the storage. Read moresourceimpl StorageInspect<ContractsAssets<'_>> for MemoryStorage
impl StorageInspect<ContractsAssets<'_>> for MemoryStorage
type Error = Infallible
sourcefn get(
&self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Cow<'_, Word>>, Infallible>
fn get(
&self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Cow<'_, Word>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.sourcefn contains_key(&self, key: &(&ContractId, &AssetId)) -> Result<bool, Infallible>
fn contains_key(&self, key: &(&ContractId, &AssetId)) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.sourceimpl StorageInspect<ContractsInfo> for MemoryStorage
impl StorageInspect<ContractsInfo> for MemoryStorage
type Error = Infallible
sourcefn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
fn get(
&self,
key: &ContractId
) -> Result<Option<Cow<'_, (Salt, Bytes32)>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.sourceimpl StorageInspect<ContractsRawCode> for MemoryStorage
impl StorageInspect<ContractsRawCode> for MemoryStorage
type Error = Infallible
sourcefn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
fn get(&self, key: &ContractId) -> Result<Option<Cow<'_, Contract>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.sourcefn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
fn contains_key(&self, key: &ContractId) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.sourceimpl StorageInspect<ContractsState<'_>> for MemoryStorage
impl StorageInspect<ContractsState<'_>> for MemoryStorage
type Error = Infallible
sourcefn get(
&self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
fn get(
&self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Cow<'_, Bytes32>>, Infallible>
Retrieve
Cow<Value>
such as Key->Value
.sourcefn contains_key(&self, key: &(&ContractId, &Bytes32)) -> Result<bool, Infallible>
fn contains_key(&self, key: &(&ContractId, &Bytes32)) -> Result<bool, Infallible>
Return
true
if there is a Key
mapping to a value in the storage.sourceimpl StorageMutate<ContractsAssets<'_>> for MemoryStorage
impl StorageMutate<ContractsAssets<'_>> for MemoryStorage
sourcefn insert(
&mut self,
key: &(&ContractId, &AssetId),
value: &Word
) -> Result<Option<Word>, Infallible>
fn insert(
&mut self,
key: &(&ContractId, &AssetId),
value: &Word
) -> Result<Option<Word>, Infallible>
Append
Key->Value
mapping to the storage. Read moresourcefn remove(
&mut self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Word>, Infallible>
fn remove(
&mut self,
key: &(&ContractId, &AssetId)
) -> Result<Option<Word>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresourceimpl StorageMutate<ContractsInfo> for MemoryStorage
impl StorageMutate<ContractsInfo> for MemoryStorage
sourcefn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Infallible>
fn insert(
&mut self,
key: &ContractId,
value: &(Salt, Bytes32)
) -> Result<Option<(Salt, Bytes32)>, Infallible>
Append
Key->Value
mapping to the storage. Read moresourcefn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
fn remove(
&mut self,
key: &ContractId
) -> Result<Option<(Salt, Bytes32)>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresourceimpl StorageMutate<ContractsRawCode> for MemoryStorage
impl StorageMutate<ContractsRawCode> for MemoryStorage
sourcefn insert(
&mut self,
key: &ContractId,
value: &[u8]
) -> Result<Option<Contract>, Infallible>
fn insert(
&mut self,
key: &ContractId,
value: &[u8]
) -> Result<Option<Contract>, Infallible>
Append
Key->Value
mapping to the storage. Read moresourcefn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
fn remove(&mut self, key: &ContractId) -> Result<Option<Contract>, Infallible>
Remove
Key->Value
mapping from the storage. Read moresourceimpl StorageMutate<ContractsState<'_>> for MemoryStorage
impl StorageMutate<ContractsState<'_>> for MemoryStorage
sourcefn insert(
&mut self,
key: &(&ContractId, &Bytes32),
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
fn insert(
&mut self,
key: &(&ContractId, &Bytes32),
value: &Bytes32
) -> Result<Option<Bytes32>, Infallible>
Append
Key->Value
mapping to the storage. Read moresourcefn remove(
&mut self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Bytes32>, Infallible>
fn remove(
&mut self,
key: &(&ContractId, &Bytes32)
) -> Result<Option<Bytes32>, Infallible>
Remove
Key->Value
mapping from the storage. Read moreAuto Trait Implementations
impl RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnwindSafe for MemoryStorage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more