diff --git a/bindings/rust/evmc-declare/src/lib.rs b/bindings/rust/evmc-declare/src/lib.rs index 4ea20c995..d58de0074 100644 --- a/bindings/rust/evmc-declare/src/lib.rs +++ b/bindings/rust/evmc-declare/src/lib.rs @@ -334,6 +334,8 @@ fn build_execute_fn(names: &VMNameSet) -> proc_macro2::TokenStream { code_size: usize ) -> ::evmc_vm::ffi::evmc_result { + use evmc_vm::EvmcVm; + assert!(!msg.is_null()); assert!(!context.is_null()); assert!(!instance.is_null()); diff --git a/bindings/rust/evmc-vm/src/container.rs b/bindings/rust/evmc-vm/src/container.rs index a8af3400d..e81d0c69c 100644 --- a/bindings/rust/evmc-vm/src/container.rs +++ b/bindings/rust/evmc-vm/src/container.rs @@ -4,8 +4,8 @@ */ use crate::EvmcVm; -use crate::ExecutionContext; -use crate::ExecutionResult; + +use std::ops::Deref; /// Container struct for EVMC instances and user-defined data. pub struct EvmcContainer { @@ -33,9 +33,15 @@ impl EvmcContainer { pub unsafe fn into_ffi_pointer(boxed: Box) -> *const ::evmc_sys::evmc_instance { Box::into_raw(boxed) as *const ::evmc_sys::evmc_instance } +} + +impl Deref for EvmcContainer +where + T: EvmcVm, +{ + type Target = T; - // TODO: Maybe this can just be done with the Deref trait. - pub fn execute(&self, code: &[u8], context: &ExecutionContext) -> ExecutionResult { - self.vm.execute(code, context) + fn deref(&self) -> &Self::Target { + &self.vm } }