componentized/directory

componentized:component

interface dev

WASM components for creating and interacting with WASM components.

interface wac-loader componentized:component/wac-loader@0.1.1-dev since 0.1.0

Composes components with WAC (WebAssembly Compositions).

Types

use type wasm

from componentized:component/types@0.1.1-dev

The bytes of a WebAssembly binary, a component unless stated otherwise.

  • list<u8>

use variant error-code

from componentized:component/types@0.1.1-dev

An error from a call.

  • malformed: malformed

    A value cannot be parsed to its expected type.

  • not-component: option<string>

    A wasm that must be a component is not, e.g. a core module. Calls accepting multiple wasms name the one that is not a component.

  • not-found: option<string>

    The item does not exist, optionally naming it, e.g. a path, URL, reference or package.

  • other: option<string>

    Any other error, with an optional message.

type package-name

  • string

type dependencysince 0.1.0

A component, named by the package a WAC composition refers to it as.

variant plansince 0.1.0

How to compose components.

  • wac: string

    A WAC script.

Functions

async functionplug: async func( socket: wasm, plugs: list<wasm>, ) -> result<wasm, error-code>since 0.1.0

Plugs the exports of each of plugs into the matching imports of socket, returning the composed component.

async functioncompose: async func( plan: plan, dependencies: list<dependency>, ) -> result<wasm, error-code>since 0.1.0

Composes the dependencies as described by plan, returning the composed component.

WIT

/// Composes components with WAC (WebAssembly Compositions).
@since(version = 0.1.0)
interface wac-loader {
  use types.{wasm, error-code};

  type package-name = string;

  /// A component, named by the package a WAC composition refers to it as.
  @since(version = 0.1.0)
  type dependency = tuple<package-name, wasm>;

  /// How to compose components.
  @since(version = 0.1.0)
  variant plan {
    /// A WAC script.
    wac(string),
  }

  /// Plugs the exports of each of `plugs` into the matching imports of `socket`, returning the
  /// composed component.
  @since(version = 0.1.0)
  plug: async func(socket: wasm, plugs: list<wasm>) -> result<wasm, error-code>;

  /// Composes the `dependencies` as described by `plan`, returning the composed component.
  @since(version = 0.1.0)
  compose: async func(plan: plan, dependencies: list<dependency>) -> result<wasm, error-code>;
}