CompositionGraph

Struct CompositionGraph 

Source
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>

Source

pub fn new() -> Self

Creates a new empty CompositionGraph.

Source

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.

Source

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.

Source

pub fn instantiate( &mut self, package_id: PackageId, linker: &mut Linker<D>, store: impl AsContextMut<Data = D>, engine: &Engine, ) -> Result<Instance, InstantiateError>
where D: 'static, C: Send + Sync + 'static,

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.

Source

pub async fn instantiate_async( &mut self, package_id: PackageId, linker: &mut Linker<D>, store: impl AsContextMut<Data = D>, engine: &Engine, ) -> Result<Instance, InstantiateError>
where D: Send + 'static, C: Send + Sync + 'static,

Like instantiate, but for asynchronous contexts.

Source

pub fn types(&self) -> &Types

Gets a reference to the type collection of the graph.

Source

pub fn types_mut(&mut self) -> &mut Types

Gets a mutable reference to the type collection of the graph.

This type collection is used to define types directly in the graph.

Trait Implementations§

Source§

impl<D, C> Debug for CompositionGraph<D, C>
where D: Debug, C: Debug + Clone,

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D, C: Clone> Default for CompositionGraph<D, C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<D, C: Clone> Index<PackageId> for CompositionGraph<D, C>

Source§

type Output = Package

The returned type after indexing.
Source§

fn index(&self, index: PackageId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.