pub struct ExportFunctionMetadata {
    pub host_env: *mut c_void,
    pub import_init_function_ptr: Option<ImportInitializerFuncPtr>,
    pub host_env_clone_fn: fn(_: *mut c_void) -> *mut c_void,
    pub host_env_drop_fn: unsafe fn(_: *mut c_void),
}
Expand description

Extra metadata about ExportFunctions.

The metadata acts as a kind of manual virtual dispatch. We store the user-supplied WasmerEnv as a void pointer and have methods on it that have been adapted to accept a void pointer.

This struct owns the original host_env, thus when it gets dropped it calls the drop function on it.

Fields§

§host_env: *mut c_void

This field is stored here to be accessible by Drop.

At the time it was added, it’s not accessed anywhere outside of the Drop implementation. This field is the “master copy” of the env, that is, the original env passed in by the user. Every time we create an Instance we clone this with the host_env_clone_fn field.

Thus, we only bother to store the master copy at all here so that we can free it.

See wasmer_vm::export::VMFunction::vmctx for the version of this pointer that is used by the VM when creating an Instance.

§import_init_function_ptr: Option<ImportInitializerFuncPtr>

Function pointer to WasmerEnv::init_with_instance(&mut self, instance: &Instance).

This function is called to finish setting up the environment after we create the api::Instance.

§host_env_clone_fn: fn(_: *mut c_void) -> *mut c_void

A function analogous to Clone::clone that returns a leaked Box.

§host_env_drop_fn: unsafe fn(_: *mut c_void)

The destructor to free the host environment.

Safety

  • This function should only be called in when properly synchronized. For example, in the Drop implementation of this type.

Implementations§

source§

impl ExportFunctionMetadata

source

pub unsafe fn new( host_env: *mut c_void, import_init_function_ptr: Option<ImportInitializerFuncPtr>, host_env_clone_fn: fn(_: *mut c_void) -> *mut c_void, host_env_drop_fn: fn(_: *mut c_void) ) -> Self

Create an ExportFunctionMetadata type with information about the exported function.

Safety
  • the host_env must be Send.
  • all function pointers must work on any thread.

Trait Implementations§

source§

impl Debug for ExportFunctionMetadata

source§

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

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

impl Drop for ExportFunctionMetadata

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl PartialEq<ExportFunctionMetadata> for ExportFunctionMetadata

source§

fn eq(&self, other: &ExportFunctionMetadata) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Send for ExportFunctionMetadata

This can be Send because host_env comes from WasmerEnv which is Send. Therefore all operations should work on any thread.

source§

impl StructuralPartialEq for ExportFunctionMetadata

source§

impl Sync for ExportFunctionMetadata

This data may be shared across threads, drop is an unsafe function pointer, so care must be taken when calling it.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.