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_native_function() has been renamed to get_typed_function(), just like NativeFunc has been renamed to TypedFunction.
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_with_generics_weak<'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_weak<'a, T, Args, Rets>(
&'a self,
name: &str
) -> Result<T, ExportError> where
Args: WasmTypeList,
Rets: WasmTypeList,
T: ExportableWithGenerics<'a, Args, Rets>,
Like get_with_generics
but with a WeakReference to the InstanceRef
internally.
This is useful for passing data into Context data, for example.
sourcepub fn get_extern(&self, name: &str) -> Option<&Extern>
pub fn get_extern(&self, name: &str) -> Option<&Extern>
Get an export as an Extern
.
sourcepub fn contains<S>(&self, name: S) -> bool where
S: Into<String>,
pub fn contains<S>(&self, name: S) -> bool where
S: Into<String>,
Returns true if the Exports
contains the given export name.
sourcepub fn iter(
&self
) -> ExportsIterator<'_, impl Iterator<Item = (&String, &Extern)>>ⓘNotable traits for ExportsIterator<'a, I>impl<'a, I> Iterator for ExportsIterator<'a, I> where
I: Iterator<Item = (&'a String, &'a Extern)> + Sized, type Item = (&'a String, &'a Extern);
pub fn iter(
&self
) -> ExportsIterator<'_, impl Iterator<Item = (&String, &Extern)>>ⓘNotable traits for ExportsIterator<'a, I>impl<'a, I> Iterator for ExportsIterator<'a, I> where
I: Iterator<Item = (&'a String, &'a Extern)> + Sized, type Item = (&'a String, &'a Extern);
I: Iterator<Item = (&'a String, &'a Extern)> + Sized, type Item = (&'a String, &'a Extern);
Get an iterator over the exports.
Trait Implementations
sourceimpl FromIterator<(String, Extern)> for Exports
impl FromIterator<(String, Extern)> for Exports
sourceimpl<'a> IntoIterator for &'a Exports
impl<'a> IntoIterator for &'a Exports
Auto Trait Implementations
impl RefUnwindSafe for Exports
impl Send for Exports
impl Sync for Exports
impl Unpin for Exports
impl UnwindSafe for Exports
Blanket Implementations
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
impl<T> Upcastable for T where
T: 'static + Any + Send + Sync,
sourcefn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
sourcefn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more