pub struct ImportObject {
pub allow_missing_functions: bool,
/* private fields */
}
Expand description
Fields§
§allow_missing_functions: bool
Allow missing functions to be generated and instantiation to continue when required functions are not provided.
Implementations§
Source§impl ImportObject
impl ImportObject
Sourcepub fn new_with_data<F>(state_creator: F) -> Self
pub fn new_with_data<F>(state_creator: F) -> Self
Create a new ImportObject
which generates data from the provided state creator.
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>>
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);
// ...
}
Sourcepub fn with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func,
) -> Option<InnerRet>
pub fn with_namespace<Func, InnerRet>( &self, namespace: &str, f: Func, ) -> Option<InnerRet>
Apply a function on the namespace if it exists
If your function can fail, consider using maybe_with_namespace
Sourcepub fn maybe_with_namespace<Func, InnerRet>(
&self,
namespace: &str,
f: Func,
) -> Option<InnerRet>
pub fn maybe_with_namespace<Func, InnerRet>( &self, namespace: &str, f: Func, ) -> 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))
}
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.
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 Extend<(String, String, Export)> for ImportObject
impl Extend<(String, String, Export)> for ImportObject
Source§fn extend<T: IntoIterator<Item = (String, String, Export)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (String, String, Export)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl IntoIterator for ImportObject
impl IntoIterator 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> 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