multiversx_sc_scenario::api

Trait VMHooksApiBackend

Source
pub trait VMHooksApiBackend:
    Clone
    + Send
    + Sync
    + 'static {
    type HandleType: HandleConstraints;

    // Required methods
    fn with_vm_hooks<R, F>(f: F) -> R
       where F: FnOnce(&dyn VMHooks) -> R;
    fn with_static_data<R, F>(f: F) -> R
       where F: FnOnce(&StaticVarData) -> R;

    // Provided methods
    fn with_vm_hooks_ctx_1<R, F>(_handle: Self::HandleType, f: F) -> R
       where F: FnOnce(&dyn VMHooks) -> R { ... }
    fn with_vm_hooks_ctx_2<R, F>(
        _handle1: Self::HandleType,
        _handle2: Self::HandleType,
        f: F,
    ) -> R
       where F: FnOnce(&dyn VMHooks) -> R { ... }
    fn with_vm_hooks_ctx_3<R, F>(
        _handle1: Self::HandleType,
        _handle2: Self::HandleType,
        _handle3: Self::HandleType,
        f: F,
    ) -> R
       where F: FnOnce(&dyn VMHooks) -> R { ... }
    fn assert_live_handle(_handle: &Self::HandleType) { ... }
}

Required Associated Types§

Source

type HandleType: HandleConstraints

We use a single handle type for all handles.

Required Methods§

Source

fn with_vm_hooks<R, F>(f: F) -> R
where F: FnOnce(&dyn VMHooks) -> R,

All communication with the VM happens via this method.

Source

fn with_static_data<R, F>(f: F) -> R
where F: FnOnce(&StaticVarData) -> R,

Static data does not belong to the VM, or to the VM hooks. It belongs to the contract only.

Provided Methods§

Source

fn with_vm_hooks_ctx_1<R, F>(_handle: Self::HandleType, f: F) -> R
where F: FnOnce(&dyn VMHooks) -> R,

Source

fn with_vm_hooks_ctx_2<R, F>( _handle1: Self::HandleType, _handle2: Self::HandleType, f: F, ) -> R
where F: FnOnce(&dyn VMHooks) -> R,

Source

fn with_vm_hooks_ctx_3<R, F>( _handle1: Self::HandleType, _handle2: Self::HandleType, _handle3: Self::HandleType, f: F, ) -> R
where F: FnOnce(&dyn VMHooks) -> R,

Source

fn assert_live_handle(_handle: &Self::HandleType)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§