Struct wasmer_runtime_core_fl::import::ImportObject [−][src]
pub struct ImportObject { pub allow_missing_functions: bool, // some fields omitted }
Expand description
Fields
allow_missing_functions: bool
Allow missing functions to be generated and instantiation to continue when required functions are not provided.
Implementations
Create a new ImportObject
which generates data from the provided state creator.
pub fn register<S, N>(
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace>> where
S: Into<String>,
N: LikeNamespace + Send + 'static,
pub fn register<S, N>(
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace>> where
S: Into<String>,
N: LikeNamespace + Send + 'static,
Register anything that implements LikeNamespace
as a namespace.
Usage:
fn register(instance: Instance, namespace: Namespace) { let mut import_object = ImportObject::new(); import_object.register("namespace0", instance); import_object.register("namespace1", namespace); // ... }
pub fn with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> InnerRet,
InnerRet: Sized,
pub fn with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> InnerRet,
InnerRet: Sized,
Apply a function on the namespace if it exists
If your function can fail, consider using maybe_with_namespace
pub fn maybe_with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
InnerRet: Sized,
pub fn maybe_with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
InnerRet: Sized,
The same as with_namespace
but takes a function that may fail
Usage:
fn get_export(imports: &ImportObject, namespace: &str, name: &str) -> Option<Export> { imports.maybe_with_namespace(namespace, |ns| ns.get_export(name)) }
Returns true if the ImportObject contains namespace with the provided name.
Trait Implementations
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
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
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self