pub struct Exports { /* private fields */ }
Expand description
Exports is a special kind of map that allows easily unwrapping the types of instances.
TODO: add examples of using exports
Implementations
sourceimpl Exports
impl Exports
sourcepub fn with_capacity(n: usize) -> Self
pub fn with_capacity(n: usize) -> Self
Creates a new Exports
with capacity n
.
sourcepub fn insert<S, E>(&mut self, name: S, value: E)where
S: Into<String>,
E: Into<Extern>,
pub fn insert<S, E>(&mut self, name: S, value: E)where
S: Into<String>,
E: Into<Extern>,
Insert a new export into this Exports
map.
sourcepub fn get<'a, T: Exportable<'a>>(
&'a self,
name: &str
) -> Result<&'a T, ExportError>
pub fn get<'a, T: Exportable<'a>>(
&'a self,
name: &str
) -> Result<&'a T, ExportError>
Get an export given a name
.
The get
method is specifically made for usage inside of
Rust APIs, as we can detect what’s the desired type easily.
If you want to get an export dynamically with type checking
please use the following functions: get_func
, get_memory
,
get_table
or get_global
instead.
If you want to get an export dynamically handling manually
type checking manually, please use get_extern
.
sourcepub fn get_global(&self, name: &str) -> Result<&Global, ExportError>
pub fn get_global(&self, name: &str) -> Result<&Global, ExportError>
Get an export as a Global
.
sourcepub fn get_memory(&self, name: &str) -> Result<&Memory, ExportError>
pub fn get_memory(&self, name: &str) -> Result<&Memory, ExportError>
Get an export as a Memory
.
sourcepub fn get_function(&self, name: &str) -> Result<&Function, ExportError>
pub fn get_function(&self, name: &str) -> Result<&Function, ExportError>
Get an export as a Func
.
sourcepub fn get_native_function<Args, Rets>(
&self,
store: &impl AsStoreRef,
name: &str
) -> Result<TypedFunction<Args, Rets>, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
👎Deprecated since 3.0.0: get_native_function() has been renamed to get_typed_function(), just like NativeFunc has been renamed to TypedFunction.
pub fn get_native_function<Args, Rets>(
&self,
store: &impl AsStoreRef,
name: &str
) -> Result<TypedFunction<Args, Rets>, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
Get an export as a TypedFunction
.
sourcepub fn get_typed_function<Args, Rets>(
&self,
store: &impl AsStoreRef,
name: &str
) -> Result<TypedFunction<Args, Rets>, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
pub fn get_typed_function<Args, Rets>(
&self,
store: &impl AsStoreRef,
name: &str
) -> Result<TypedFunction<Args, Rets>, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
Get an export as a TypedFunction
.
sourcepub fn get_with_generics<'a, T, Args, Rets>(
&'a self,
name: &str
) -> Result<T, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
T: ExportableWithGenerics<'a, Args, Rets>,
pub fn get_with_generics<'a, T, Args, Rets>(
&'a self,
name: &str
) -> Result<T, ExportError>where
Args: WasmTypeList,
Rets: WasmTypeList,
T: ExportableWithGenerics<'a, Args, Rets>,
Hack to get this working with nativefunc too
sourcepub fn get_extern(&self, name: &str) -> Option<&Extern>
pub fn get_extern(&self, name: &str) -> Option<&Extern>
Get an export as an Extern
.