[−][src]Struct holochain_wasmer_host::prelude::ImportObject
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:
let import_object = imports! { "env" => { "foo" => func!(foo), }, }; fn foo(_: &mut Ctx, n: i32) -> i32 { n }
Fields
allow_missing_functions: bool
Allow missing functions to be generated and instantiation to continue when required functions are not provided.
Implementations
impl ImportObject
[src]
pub fn new() -> ImportObject
[src]
Create a new ImportObject
.
pub fn new_with_data<F>(state_creator: F) -> ImportObject where
F: Fn() -> (*mut c_void, fn(*mut c_void)) + 'static + Send + Sync,
[src]
F: Fn() -> (*mut c_void, fn(*mut c_void)) + 'static + Send + Sync,
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 + 'static, Global>> where
N: LikeNamespace + Send + 'static,
S: Into<String>,
[src]
&mut self,
name: S,
namespace: N
) -> Option<Box<dyn LikeNamespace + 'static, Global>> where
N: LikeNamespace + Send + 'static,
S: Into<String>,
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,
[src]
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> InnerRet,
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>,
[src]
&self,
namespace: &str,
f: Func
) -> Option<InnerRet> where
Func: FnOnce(&(dyn LikeNamespace + Send)) -> Option<InnerRet>,
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)) }
pub fn clone_ref(&self) -> ImportObject
[src]
Create a clone ref of this namespace.
Trait Implementations
impl Extend<(String, String, Export)> for ImportObject
[src]
pub fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = (String, String, Export)>,
[src]
T: IntoIterator<Item = (String, String, Export)>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl IntoIterator for ImportObject
[src]
type IntoIter = ImportObjectIterator
Which kind of iterator are we turning this into?
type Item = (String, String, Export)
The type of the elements being iterated over.
pub fn into_iter(self) -> <ImportObject as IntoIterator>::IntoIter
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ImportObject
[src]
impl Send for ImportObject
[src]
impl Sync for ImportObject
[src]
impl Unpin for ImportObject
[src]
impl !UnwindSafe for ImportObject
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,