multiversx_chain_vm::tx_mock

Struct TxContextRef

Source
pub struct TxContextRef(/* private fields */);
Expand description

The VM API implementation based on a blockchain mock written in Rust. Implemented as a smart pointer to a TxContext structure, which tracks a blockchain transaction.

Implementations§

Source§

impl TxContextRef

Source

pub fn new(tx_context_arc: Arc<TxContext>) -> Self

Source

pub fn new_from_static() -> Self

Source

pub fn dummy() -> Self

Source

pub fn into_blockchain_updates(self) -> BlockchainUpdate

Source

pub fn into_tx_result(self) -> TxResult

Consumes the current API and returns the contained output. Should be called at the end of a tx execution. Will fail if any other references to the tx context survive, this must be the last.

Source

pub fn replace_tx_result_with_error(self, tx_panic: TxPanic)

The current method for signalling that the current execution is failed, and with what error.

Note: does not terminate execution or panic, that is handled separately.

Methods from Deref<Target = TxContext>§

Source

pub fn input_ref(&self) -> &TxInput

Source

pub fn blockchain_cache(&self) -> &TxCache

Source

pub fn blockchain_cache_arc(&self) -> Arc<TxCache>

Source

pub fn blockchain_ref(&self) -> &BlockchainState

Source

pub fn with_account<R, F>(&self, address: &VMAddress, f: F) -> R
where F: FnOnce(&AccountData) -> R,

Source

pub fn with_account_or_else<R, F, Else>( &self, address: &VMAddress, f: F, or_else: Else, ) -> R
where F: FnOnce(&AccountData) -> R, Else: FnOnce() -> R,

Source

pub fn with_contract_account<R, F>(&self, f: F) -> R
where F: FnOnce(&AccountData) -> R,

Source

pub fn with_account_mut<R, F>(&self, address: &VMAddress, f: F) -> R
where F: FnOnce(&mut AccountData) -> R,

Source

pub fn with_contract_account_mut<R, F>(&self, f: F) -> R
where F: FnOnce(&mut AccountData) -> R,

Source

pub fn m_types_lock(&self) -> MutexGuard<'_, TxManagedTypes>

Source

pub fn back_transfers_lock(&self) -> MutexGuard<'_, BackTransfers>

Source

pub fn result_lock(&self) -> MutexGuard<'_, TxResult>

Source

pub fn extract_result(&self) -> TxResult

Source

pub fn rng_lock(&self) -> MutexGuard<'_, BlockchainRng>

Source

pub fn create_new_contract( &self, new_address: &VMAddress, contract_path: Vec<u8>, code_metadata: VMCodeMetadata, contract_owner: VMAddress, )

Trait Implementations§

Source§

impl Clone for TxContextRef

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TxContextRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for TxContextRef

Source§

type Target = TxContext

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.