Expand description
A library for defining, encoding, and decoding WebAssembly composition graphs.
An example of composing two components together using a CompositionGraph
:
use wac_graph::{CompositionGraph, EncodeOptions, types::Package};
let mut graph = CompositionGraph::new();
// Register the packages with the graph
// It is assumed that `my:package1` exports a function named `a`,
// while `my:package2` imports a function named `b`.
let pkg = Package::from_file("my:package1", None, "package1.wasm", graph.types_mut())?;
let package1 = graph.register_package(pkg)?;
let pkg = Package::from_file("my:package2", None, "package2.wasm", graph.types_mut())?;
let package2 = graph.register_package(pkg)?;
// Instantiate package `my:package1`
let instantiation1 = graph.instantiate(package1);
// Alias the `a` export of the `my:package1` instance
let a = graph.alias_instance_export(instantiation1, "a")?;
// Instantiate package `my:package2`
let instantiation2 = graph.instantiate(package2);
// Set argument `b` of the instantiation of `my:package2` to `a`
graph.set_instantiation_argument(instantiation2, "b", a)?;
// Finally, encode the graph into a new component
let bytes = graph.encode(EncodeOptions::default())?;
Re-exports§
pub use wac_types as types;
Structs§
- Composition
Graph - Represents a composition graph.
- Encode
Options - The options for encoding a composition graph.
- Node
- Represents a node in a composition graph.
- NodeId
- An identifier for a node in a composition graph.
- Package
Id - An identifier for a package in a composition graph.
- Processor
- Information about the tool that processed the graph.
Enums§
- Alias
Error - Represents an error that can occur when aliasing an instance export in a composition graph.
- Decode
Error - Represents an error that can occur when decoding a composition graph.
- Define
Type Error - Represents an error that can occur when defining a type in a composition graph.
- Encode
Error - Represents an error that can occur when encoding a composition graph.
- Export
Error - Represents an error that can occur when exporting a node from a composition graph.
- Import
Error - Represents an error that can occur when importing an item in a composition graph.
- Instantiation
Argument Error - Represents an error that can occur when setting an instantiation argument in a composition graph.
- Node
Kind - Represents the kind of a node in a composition graph.
- Plug
Error - Represents an error that can occur when plugging components together.
- Register
Package Error - Represents an error that can occur when registering a package with a composition graph.
- Unexport
Error - Represents an error that can occur when unexporting a node in a composition graph.
Functions§
- plug
- Take the exports of the plug components and plug them into the socket component.