Propagate optional import names to the wasmtime/C API
With the module linking proposal the field name on imports is now optional, and only the module is required to be specified. This commit propagates this API change to the boundary of wasmtime's API, ensuring consumers are aware of what's optional with module linking and what isn't. Note that it's expected that all existing users will either update accordingly or unwrap the result since module linking is presumably disabled.
This commit is contained in:
@@ -581,7 +581,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
&mut self,
|
||||
index: TypeIndex,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
assert_eq!(
|
||||
self.info.functions.len(),
|
||||
@@ -591,7 +591,7 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
self.info.functions.push(Exportable::new(index));
|
||||
self.info
|
||||
.imported_funcs
|
||||
.push((String::from(module), String::from(field)));
|
||||
.push((String::from(module), String::from(field.unwrap())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -609,12 +609,12 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
&mut self,
|
||||
global: Global,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
self.info.globals.push(Exportable::new(global));
|
||||
self.info
|
||||
.imported_globals
|
||||
.push((String::from(module), String::from(field)));
|
||||
.push((String::from(module), String::from(field.unwrap())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -627,12 +627,12 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
&mut self,
|
||||
table: Table,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
self.info.tables.push(Exportable::new(table));
|
||||
self.info
|
||||
.imported_tables
|
||||
.push((String::from(module), String::from(field)));
|
||||
.push((String::from(module), String::from(field.unwrap())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -672,12 +672,12 @@ impl<'data> ModuleEnvironment<'data> for DummyEnvironment {
|
||||
&mut self,
|
||||
memory: Memory,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
self.info.memories.push(Exportable::new(memory));
|
||||
self.info
|
||||
.imported_memories
|
||||
.push((String::from(module), String::from(field)));
|
||||
.push((String::from(module), String::from(field.unwrap())));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
index: TypeIndex,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Declares a table import to the environment.
|
||||
@@ -682,7 +682,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
table: Table,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Declares a memory import to the environment.
|
||||
@@ -690,7 +690,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
memory: Memory,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Declares an event import to the environment.
|
||||
@@ -698,7 +698,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
event: Event,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
drop((event, module, field));
|
||||
Err(WasmError::Unsupported("wasm events".to_string()))
|
||||
@@ -709,7 +709,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
global: Global,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Declares a module import to the environment.
|
||||
@@ -717,7 +717,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
ty_index: TypeIndex,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
drop((ty_index, module, field));
|
||||
Err(WasmError::Unsupported("module linking".to_string()))
|
||||
@@ -728,7 +728,7 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
||||
&mut self,
|
||||
ty_index: TypeIndex,
|
||||
module: &'data str,
|
||||
field: &'data str,
|
||||
field: Option<&'data str>,
|
||||
) -> WasmResult<()> {
|
||||
drop((ty_index, module, field));
|
||||
Err(WasmError::Unsupported("module linking".to_string()))
|
||||
|
||||
Reference in New Issue
Block a user