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_voidThis 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 near_vm_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_voidA 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 Dropimplementation of this type.
Implementations§
Source§impl ExportFunctionMetadata
 
impl ExportFunctionMetadata
Sourcepub 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
 
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_envmust beSend.
- all function pointers must work on any thread.
Trait Implementations§
Source§impl Debug for ExportFunctionMetadata
 
impl Debug for ExportFunctionMetadata
Source§impl Drop for ExportFunctionMetadata
 
impl Drop for ExportFunctionMetadata
Source§impl PartialEq for ExportFunctionMetadata
 
impl PartialEq for ExportFunctionMetadata
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.
impl StructuralPartialEq for ExportFunctionMetadata
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§
impl Freeze for ExportFunctionMetadata
impl RefUnwindSafe for ExportFunctionMetadata
impl Unpin for ExportFunctionMetadata
impl UnwindSafe for ExportFunctionMetadata
Blanket Implementations§
Source§impl<T> ArchivePointee for T
 
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
 
type ArchivedMetadata = ()
Source§fn pointer_metadata(
    _: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
 
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§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
Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
 
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
 
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
 
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
 
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
 
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.