pub struct CompositionGraph<D, C: Clone = ()> { /* private fields */ }
Expand description
A graph for composing multiple WebAssembly components into a single linker, while allowing for automatic insertion of “trampoline” functions between cross-component calls.
Implementations§
Source§impl<D, C: Clone> CompositionGraph<D, C>
impl<D, C: Clone> CompositionGraph<D, C>
Sourcepub fn set_import_filter<F>(&mut self, filter: F)where
F: ImportFilter + 'static,
pub fn set_import_filter<F>(&mut self, filter: F)where
F: ImportFilter + 'static,
Filters package imports for graph inclusion.
The filter can be removed by using the default ImportRule::default()
filter.
Sourcepub fn add_package(
&mut self,
name: String,
version: Version,
bytes: impl Into<Vec<u8>>,
trampoline: impl DynPackageTrampoline<D, C>,
) -> Result<PackageId, AddPackageError>
pub fn add_package( &mut self, name: String, version: Version, bytes: impl Into<Vec<u8>>, trampoline: impl DynPackageTrampoline<D, C>, ) -> Result<PackageId, AddPackageError>
Adds a package (component) to the composition graph.
Components can be added in any order, and dependencies will be resolved at instantiation time.
Sourcepub fn instantiate(
&mut self,
package_id: PackageId,
linker: &mut Linker<D>,
store: impl AsContextMut<Data = D>,
engine: &Engine,
) -> Result<Instance, InstantiateError>
pub fn instantiate( &mut self, package_id: PackageId, linker: &mut Linker<D>, store: impl AsContextMut<Data = D>, engine: &Engine, ) -> Result<Instance, InstantiateError>
Instantiates a component from the composition graph, resolving all component dependencies.
Host functions and other resources can be provided through the linker
argument prior to
instantiation.
Sourcepub async fn instantiate_async(
&mut self,
package_id: PackageId,
linker: &mut Linker<D>,
store: impl AsContextMut<Data = D>,
engine: &Engine,
) -> Result<Instance, InstantiateError>
pub async fn instantiate_async( &mut self, package_id: PackageId, linker: &mut Linker<D>, store: impl AsContextMut<Data = D>, engine: &Engine, ) -> Result<Instance, InstantiateError>
Like instantiate
, but for asynchronous contexts.
Trait Implementations§
Source§impl<D, C> Debug for CompositionGraph<D, C>
impl<D, C> Debug for CompositionGraph<D, C>
Source§impl<D, C: Clone> Default for CompositionGraph<D, C>
impl<D, C: Clone> Default for CompositionGraph<D, C>
Auto Trait Implementations§
impl<D, C> Freeze for CompositionGraph<D, C>
impl<D, C = ()> !RefUnwindSafe for CompositionGraph<D, C>
impl<D, C = ()> !Send for CompositionGraph<D, C>
impl<D, C = ()> !Sync for CompositionGraph<D, C>
impl<D, C> Unpin for CompositionGraph<D, C>where
C: Unpin,
impl<D, C = ()> !UnwindSafe for CompositionGraph<D, C>
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
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 more