Struct radix_engine::vm::wasm::wasmi::WasmiModule
source · pub struct WasmiModule {
template_store: Store<FakeWasmiInstanceEnv>,
template_instance: Instance,
code_size_bytes: usize,
}
Expand description
A WasmiModule
defines a parsed WASM module “template” Instance (with imports already defined)
and Store, which keeps user data.
“Template” (Store, Instance) tuple are cached together, and never to be invoked.
Upon instantiation Instance and Store are cloned, so the state is not shared between instances.
It is safe to clone an Instance
and a Store
, since they don’t use pointers, but Arena
allocator. Instance
is owned by Store
, it is basically some offset within Store
’s vector
of Instance
s. So after clone we receive the same Store
, where we are able to set different
data, more specifically a runtime_ptr
.
Also, it is correctly Send + Sync
(under the assumption that the data in the Store is set to
a valid value upon invocation , because this is the thing which is cached in the
ScryptoInterpreter caches.
Fields§
§template_store: Store<FakeWasmiInstanceEnv>
§template_instance: Instance
§code_size_bytes: usize
Implementations§
source§impl WasmiModule
impl WasmiModule
pub fn new(code: &[u8]) -> Result<Self, WasmiInstantiationError>
pub fn host_funcs_set( module: &Module, store: &mut Store<WasmiInstanceEnv> ) -> Result<InstancePre, Error>
fn instantiate(&self) -> WasmiInstance
Auto Trait Implementations§
impl !RefUnwindSafe for WasmiModule
impl Send for WasmiModule
impl Sync for WasmiModule
impl Unpin for WasmiModule
impl !UnwindSafe for WasmiModule
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self
to type T
. The semantics of numeric casting with the as
operator are followed, so <T as As>::as_::<U>
can be used in the same way as T as U
for numeric conversions. Read moresource§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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.