Improved docs and fixed comments

This commit is contained in:
Syrus Akbary
2021-11-25 10:35:26 +01:00
parent c0bcef9feb
commit c6d2a08d0d
2 changed files with 16 additions and 4 deletions

View File

@@ -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 {

View File

@@ -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