Struct wasmy_vm::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 new() -> ImportObject
pub fn new() -> ImportObject
Create a new 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 + 'static, Global>> where
S: Into<String>,
N: 'static + LikeNamespace + Send + Sync,
pub fn register<S, N>(
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace + 'static, Global>> where
S: Into<String>,
N: 'static + LikeNamespace + Send + Sync,
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
type IntoIter = ImportObjectIterator
type IntoIter = ImportObjectIterator
Which kind of iterator are we turning this into?
sourcefn into_iter(self) -> <ImportObject as IntoIterator>::IntoIter
fn into_iter(self) -> <ImportObject as IntoIterator>::IntoIter
Creates an iterator from a value. Read more
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
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<T> ChainableNamedResolver for T where
T: NamedResolver + Send + Sync,
impl<T> ChainableNamedResolver for T where
T: NamedResolver + Send + Sync,
fn 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
fn 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
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> 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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> Upcastable for T where
T: 'static + Any + Debug,
impl<T> Upcastable for T where
T: 'static + Any + Debug,
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_box(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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