mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 16:20:49 +00:00
Fix bug and un-deprecate Instance::call
This commit is contained in:
parent
836711f7cd
commit
bde319d9fb
@ -230,6 +230,23 @@ impl Instance {
|
||||
/// This returns `CallResult<Vec<Value>>` in order to support
|
||||
/// the future multi-value returns WebAssembly feature.
|
||||
///
|
||||
/// Consider using the more explicit [`Exports::get`]` with [`DynFunc::call`]
|
||||
/// instead. For example:
|
||||
///
|
||||
/// ```
|
||||
/// # use wasmer_runtime_core::types::Value;
|
||||
/// # use wasmer_runtime_core::error::Result;
|
||||
/// # use wasmer_runtime_core::Instance;
|
||||
/// # use wasmer_runtime_core::DynFunc;
|
||||
/// # fn call_foo(instance: &mut Instance) -> Result<()> {
|
||||
/// // ...
|
||||
/// let foo: DynFunc = instance.exports.get("foo")?;
|
||||
/// let results = foo.call(&[Value::I32(42)])?;
|
||||
/// // ...
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// # Usage:
|
||||
/// ```
|
||||
/// # use wasmer_runtime_core::types::Value;
|
||||
@ -242,10 +259,6 @@ impl Instance {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[deprecated(
|
||||
since = "0.17.0",
|
||||
note = "Please use `let f: DynFunc = instance.exports.get(name)?; f.call(params)?;` instead"
|
||||
)]
|
||||
pub fn call(&self, name: &str, params: &[Value]) -> CallResult<Vec<Value>> {
|
||||
let func: DynFunc = self.exports.get(name)?;
|
||||
func.call(params)
|
||||
|
@ -180,14 +180,14 @@ impl Module {
|
||||
/// // For example, here we get all the names of the functions exported by this module.
|
||||
/// let function_names =
|
||||
/// module.exports()
|
||||
/// .filter(|ed| ed.kind == ExportType::Function)
|
||||
/// .filter(|ed| ed.ty == ExportType::Function)
|
||||
/// .map(|ed| ed.name.to_string())
|
||||
/// .collect::<Vec<String>>();
|
||||
///
|
||||
/// // And here we count the number of global variables exported by this module.
|
||||
/// let num_globals =
|
||||
/// module.exports()
|
||||
/// .filter(|ed| ed.kind == ExportType::Global)
|
||||
/// .filter(|ed| ed.ty == ExportType::Global)
|
||||
/// .count();
|
||||
/// # }
|
||||
/// ```
|
||||
|
Loading…
x
Reference in New Issue
Block a user