Struct fuel_vm::interpreter::RuntimeBalances
source · [−]pub struct RuntimeBalances { /* private fields */ }
Expand description
Structure to encapsulate asset balances for VM runtime
Implementations
sourceimpl RuntimeBalances
impl RuntimeBalances
sourcepub fn try_from_iter<T>(iter: T) -> Result<Self, ValidationError> where
T: IntoIterator<Item = (AssetId, Word)>,
pub fn try_from_iter<T>(iter: T) -> Result<Self, ValidationError> 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>(self, vm: &mut Interpreter<S>)
pub fn to_vm<S>(self, vm: &mut Interpreter<S>)
Write all assets into the VM memory.
Trait Implementations
sourceimpl Clone for RuntimeBalances
impl Clone for RuntimeBalances
sourcefn clone(&self) -> RuntimeBalances
fn clone(&self) -> RuntimeBalances
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 more
sourceimpl Debug for RuntimeBalances
impl Debug for RuntimeBalances
sourceimpl Default for RuntimeBalances
impl Default for RuntimeBalances
sourcefn default() -> RuntimeBalances
fn default() -> RuntimeBalances
Returns the “default value” for a type. Read more
sourceimpl From<&CheckedTransaction> for RuntimeBalances
impl From<&CheckedTransaction> for RuntimeBalances
sourcefn from(tx: &CheckedTransaction) -> Self
fn from(tx: &CheckedTransaction) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for RuntimeBalances
impl Send for RuntimeBalances
impl Sync for RuntimeBalances
impl Unpin for RuntimeBalances
impl UnwindSafe for RuntimeBalances
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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