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§
Source§impl ImportObject
impl ImportObject
Sourcepub fn new() -> ImportObject
pub fn new() -> ImportObject
Create a new ImportObject
.
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>>
pub fn register<S, N>( &mut self, name: S, namespace: N, ) -> Option<Box<dyn LikeNamespace>>
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§
Source§impl Clone for ImportObject
impl Clone for ImportObject
Source§fn clone(&self) -> ImportObject
fn clone(&self) -> ImportObject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ImportObject
impl Debug for ImportObject
Source§impl Default for ImportObject
impl Default for ImportObject
Source§fn default() -> ImportObject
fn default() -> ImportObject
Returns the “default value” for a type. Read more
Source§impl IntoIterator for ImportObject
impl IntoIterator for ImportObject
Source§impl NamedResolver for ImportObject
impl NamedResolver for ImportObject
Auto Trait Implementations§
impl Freeze for ImportObject
impl RefUnwindSafe for ImportObject
impl Send for ImportObject
impl Sync for ImportObject
impl Unpin for ImportObject
impl UnwindSafe for ImportObject
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§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.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ChainableNamedResolver for T
impl<T> ChainableNamedResolver for T
Source§fn chain_front<U>(self, other: U) -> NamedResolverChain<U, Self>
fn chain_front<U>(self, other: U) -> NamedResolverChain<U, Self>
Chain a resolver in front of the current resolver. Read more
Source§fn chain_back<U>(self, other: U) -> NamedResolverChain<Self, U>
fn chain_back<U>(self, other: U) -> NamedResolverChain<Self, U>
Chain a resolver behind the current resolver. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Resolver for Twhere
T: NamedResolver,
impl<T> Resolver for Twhere
T: NamedResolver,
Source§impl<T> Upcastable for T
impl<T> Upcastable for T
Source§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
Source§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref