Struct fuel_vm::interpreter::RuntimeBalances
source · pub struct RuntimeBalances { /* private fields */ }
Expand description
Structure to encapsulate asset balances for VM runtime
Implementations§
source§impl RuntimeBalances
impl RuntimeBalances
sourcepub fn try_from_iter<T>(iter: T) -> Result<Self, CheckError>where
T: IntoIterator<Item = (AssetId, Word)>,
pub fn try_from_iter<T>(iter: T) -> Result<Self, CheckError>where
T: IntoIterator<Item = (AssetId, Word)>,
Attempt to create a set of runtime balances from an iterator of pairs.
This will fail if, and only if, the provided asset/balance pair isn’t consistent or a balance overflows.
sourcepub fn balance(&self, asset: &AssetId) -> Option<Word>
pub fn balance(&self, asset: &AssetId) -> Option<Word>
Fetch the balance of a given Id, if set.
sourcepub fn checked_balance_add(
&mut self,
memory: &mut [u8],
asset: &AssetId,
value: Word
) -> Option<Word>
pub fn checked_balance_add(
&mut self,
memory: &mut [u8],
asset: &AssetId,
value: Word
) -> Option<Word>
Attempt to add the balance of an asset, updating the VM memory in the appropriate offset
Note: This will not append a new asset into the set since all the assets must be created during VM initialization and any additional asset would imply reordering the memory representation of the balances since they must always be ordered, as in the protocol.
sourcepub fn checked_balance_sub(
&mut self,
memory: &mut [u8],
asset: &AssetId,
value: Word
) -> Option<Word>
pub fn checked_balance_sub(
&mut self,
memory: &mut [u8],
asset: &AssetId,
value: Word
) -> Option<Word>
Attempt to subtract the balance of an asset, updating the VM memory in the appropriate offset
sourcepub fn to_vm<S, Tx>(self, vm: &mut Interpreter<S, Tx>)where
Tx: ExecutableTransaction,
pub fn to_vm<S, Tx>(self, vm: &mut Interpreter<S, Tx>)where
Tx: ExecutableTransaction,
Write all assets into the VM memory.
Trait Implementations§
source§impl Clone for RuntimeBalances
impl Clone for RuntimeBalances
source§fn clone(&self) -> RuntimeBalances
fn clone(&self) -> RuntimeBalances
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RuntimeBalances
impl Debug for RuntimeBalances
source§impl Default for RuntimeBalances
impl Default for RuntimeBalances
source§fn default() -> RuntimeBalances
fn default() -> RuntimeBalances
Returns the “default value” for a type. Read more