multiversx_sc_scenario/api/impl_vh/
vm_hooks_backend.rs1use multiversx_chain_vm::executor::VMHooks;
2use multiversx_chain_vm_executor::VMHooksEarlyExit;
3use multiversx_sc::api::HandleConstraints;
4
5use crate::executor::debug::StaticVarData;
6
7pub trait VMHooksApiBackend: Clone + Send + Sync + 'static {
8 type HandleType: HandleConstraints;
10
11 fn with_vm_hooks<R, F>(f: F) -> R
13 where
14 F: FnOnce(&mut dyn VMHooks) -> Result<R, VMHooksEarlyExit>;
15
16 fn with_vm_hooks_ctx_1<R, F>(_handle: Self::HandleType, f: F) -> R
17 where
18 F: FnOnce(&mut dyn VMHooks) -> Result<R, VMHooksEarlyExit>,
19 {
20 Self::with_vm_hooks(f)
21 }
22
23 fn with_vm_hooks_ctx_2<R, F>(_handle1: Self::HandleType, _handle2: Self::HandleType, f: F) -> R
24 where
25 F: FnOnce(&mut dyn VMHooks) -> Result<R, VMHooksEarlyExit>,
26 {
27 Self::with_vm_hooks(f)
28 }
29
30 fn with_vm_hooks_ctx_3<R, F>(
31 _handle1: Self::HandleType,
32 _handle2: Self::HandleType,
33 _handle3: Self::HandleType,
34 f: F,
35 ) -> R
36 where
37 F: FnOnce(&mut dyn VMHooks) -> Result<R, VMHooksEarlyExit>,
38 {
39 Self::with_vm_hooks(f)
40 }
41
42 fn assert_live_handle(_handle: &Self::HandleType) {
43 }
45
46 fn with_static_data<R, F>(f: F) -> R
48 where
49 F: FnOnce(&StaticVarData) -> R;
50}