Struct wasmer::ImportObject
source · [−]pub struct ImportObject { /* private fields */ }
Expand description
All of the import data used when instantiating.
It’s suggested that you use the imports!
macro
instead of creating an ImportObject
by hand.
Usage:
use wasmer::{Exports, ImportObject, Function};
let mut import_object = ImportObject::new();
let mut env = Exports::new();
env.insert("foo", Function::new_native(foo));
import_object.register("env", env);
fn foo(n: i32) -> i32 {
n
}
Implementations
sourceimpl ImportObject
impl ImportObject
sourcepub fn get_export(&self, module: &str, name: &str) -> Option<Export>
pub fn get_export(&self, module: &str, name: &str) -> Option<Export>
Gets an export given a module and a name
Usage
let mut import_object = ImportObject::new();
import_object.get_export("module", "name");
sourcepub fn contains_namespace(&self, name: &str) -> bool
pub fn contains_namespace(&self, name: &str) -> bool
Returns true if the ImportObject contains namespace with the provided name.
sourcepub fn register<S, N>(
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace>> where
S: Into<String>,
N: LikeNamespace + Send + Sync + 'static,
pub fn register<S, N>(
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace>> where
S: Into<String>,
N: LikeNamespace + Send + Sync + 'static,
Register anything that implements LikeNamespace
as a namespace.
Usage:
let mut import_object = ImportObject::new();
import_object.register("namespace0", instance);
import_object.register("namespace1", namespace);
// ...
sourcepub fn get_namespace_exports(&self, name: &str) -> Option<Exports>
pub fn get_namespace_exports(&self, name: &str) -> Option<Exports>
Returns the contents of a namespace as an Exports
.
Returns None
if the namespace doesn’t exist or doesn’t implement the
as_exports
method.
Trait Implementations
sourceimpl Clone for ImportObject
impl Clone for ImportObject
sourcefn clone(&self) -> ImportObject
fn clone(&self) -> ImportObject
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ImportObject
impl Debug for ImportObject
sourceimpl Default for ImportObject
impl Default for ImportObject
sourcefn default() -> ImportObject
fn default() -> ImportObject
Returns the “default value” for a type. Read more
sourceimpl IntoIterator for ImportObject
impl IntoIterator for ImportObject
sourceimpl NamedResolver for ImportObject
impl NamedResolver for ImportObject
Auto Trait Implementations
impl RefUnwindSafe for ImportObject
impl Send for ImportObject
impl Sync for ImportObject
impl Unpin for ImportObject
impl UnwindSafe for ImportObject
Blanket Implementations
sourceimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
sourcepub fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
pub 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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ChainableNamedResolver for T where
T: NamedResolver + Send + Sync,
impl<T> ChainableNamedResolver for T where
T: NamedResolver + Send + Sync,
sourcefn chain_front<U>(self, other: U) -> NamedResolverChain<U, Self> where
U: NamedResolver + Send + Sync,
fn chain_front<U>(self, other: U) -> NamedResolverChain<U, Self> where
U: NamedResolver + Send + Sync,
Chain a resolver in front of the current resolver. Read more
sourcefn chain_back<U>(self, other: U) -> NamedResolverChain<Self, U> where
U: NamedResolver + Send + Sync,
fn chain_back<U>(self, other: U) -> NamedResolverChain<Self, U> where
U: NamedResolver + Send + Sync,
Chain a resolver behind the current resolver. Read more
sourceimpl<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,
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>
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> Resolver for T where
T: NamedResolver,
impl<T> Resolver for T where
T: NamedResolver,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
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