mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 13:18:20 +00:00
Improved docs and fixed comments
This commit is contained in:
@@ -112,7 +112,8 @@ impl Instance {
|
||||
/// Is expected that the function [`Instance::init_envs`] is run manually
|
||||
/// by the user in case the instance has any Wasmer imports, so the function
|
||||
/// environments are properly initiated.
|
||||
#[doc(hidden)]
|
||||
///
|
||||
/// *This method is only available when targeting JS environments*
|
||||
pub fn from_module_and_instance(
|
||||
module: &Module,
|
||||
instance: WebAssembly::Instance,
|
||||
@@ -144,8 +145,15 @@ impl Instance {
|
||||
})
|
||||
}
|
||||
|
||||
/// Initialize the given extern imports with the Instance
|
||||
#[doc(hidden)]
|
||||
/// Initialize the given extern imports with the `Instance`.
|
||||
///
|
||||
/// # Important
|
||||
///
|
||||
/// This method should be called if the Wasmer `Instance` is initialized
|
||||
/// from Javascript with an already existing `WebAssembly.Instance` but with
|
||||
/// a imports from the Rust side.
|
||||
///
|
||||
/// *This method is only available when targeting JS environments*
|
||||
pub fn init_envs(&self, imports: &[Export]) -> Result<(), InstantiationError> {
|
||||
for import in imports {
|
||||
if let Export::Function(func) = import {
|
||||
|
||||
@@ -10,11 +10,15 @@ pub struct JsImportObject {
|
||||
object: js_sys::Object,
|
||||
}
|
||||
|
||||
/// JS Objects with wasm-bindgen are not currently Send/Sync (although they
|
||||
/// are in Javascript, since we can use them safely between webworkers).
|
||||
unsafe impl Send for JsImportObject {}
|
||||
unsafe impl Sync for JsImportObject {}
|
||||
|
||||
impl JsImportObject {
|
||||
/// Create a new `JsImportObject`.
|
||||
/// Create a new `JsImportObject`, it receives a reference to a `Module` to
|
||||
/// map and assign the types of each import and the JS Object
|
||||
/// that contains the values of imports.
|
||||
///
|
||||
/// # Usage
|
||||
/// ```ignore
|
||||
|
||||
Reference in New Issue
Block a user