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 AsMut<HashMap<AssetId, Balance, RandomState>> for RuntimeBalances
impl AsMut<HashMap<AssetId, Balance, RandomState>> for RuntimeBalances
source§impl AsRef<HashMap<AssetId, Balance, RandomState>> for RuntimeBalances
impl AsRef<HashMap<AssetId, Balance, RandomState>> for RuntimeBalances
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
source§impl From<BTreeMap<AssetId, u64, Global>> for RuntimeBalances
impl From<BTreeMap<AssetId, u64, Global>> for RuntimeBalances
source§fn from(balances: InitialBalances) -> Self
fn from(balances: InitialBalances) -> Self
Converts to this type from the input type.
source§impl Index<&AssetId> for RuntimeBalances
impl Index<&AssetId> for RuntimeBalances
source§impl PartialEq<RuntimeBalances> for RuntimeBalances
impl PartialEq<RuntimeBalances> for RuntimeBalances
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§
source§impl<T> AnyDebug for Twhere
T: Any + Debug,
impl<T> AnyDebug for Twhere T: Any + Debug,
source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Returns a reference to the underlying type as
Any
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more