Skip to main content

Crate splicer

Crate splicer 

Source
Expand description

splicer — plan and generate WebAssembly component compositions.

Most users only need the two top-level entry points:

  • splice — splice middleware into an existing composition.
  • compose — synthesize a composition from N components.

Both take a typed request struct and return a typed output struct whose wac_deps field is shaped to be handed straight to wac_resolver::FileSystemPackageResolver (or formatted into a wac compose ... --dep ... shell command).

Advanced users who want more granular control can reach for the lower-level building blocks under lowlevel, or import the shared types from types.

§Quick start

let rules_yaml = std::fs::read_to_string("splice.yaml")?;
let bundle = splicer::splice(splicer::SpliceRequest {
    composition_wasm: "composition.wasm".into(),
    rules_yaml,
    package_name: "example:composition".into(),
    splits_dir: "./splits".into(),
    skip_type_check: false,
})?;

// Compose to a single Wasm component, in-process — no shelling out.
let composed: Vec<u8> = bundle.to_wasm()?;
std::fs::write("composed.wasm", &composed)?;

for adapter in &bundle.generated_adapters {
    println!(
        "generated adapter for middleware '{}' at {}",
        adapter.middleware_name, adapter.adapter_path,
    );
}

§Want to drive wac compose yourself?

Bundle::wac and Bundle::wac_deps expose the raw inputs. Write the WAC to disk and call Bundle::wac_compose_cmd to get the equivalent wac compose ... --dep ... shell command, or feed wac_deps directly into wac_resolver::FileSystemPackageResolver — the keys are fully-qualified WAC package keys, the values are PathBufs, no translation step required.

For finer control over the in-process path (e.g. a custom filesystem search base for unresolved package references), reach for compose_wac.

§Side effects on disk

Both splice and compose write files as part of their work:

  • splice writes one .wasm file per sub-component into splits_dir (the splitter pass), and may write splicer_adapter_*.wasm files alongside them (the adapter generator). Adapter paths are surfaced in Bundle::generated_adapters and Bundle::wac_deps.
  • Neither function writes the generated WAC source — that’s returned in Bundle::wac for the caller to use however they like (typically by passing the bundle to Bundle::to_wasm).

Re-exports§

pub use ::cviz;

Modules§

builtin_info
Introspection helpers for the builtins shipped with this splicer. Reads the embedded manifests so callers (CLI, custom tooling) can render the same key/default/doc surface that splice-time validation enforces. Bulk of the module stays private — these are the only pieces that make sense to expose.
lowlevel
Direct access to splicer’s internal pipeline stages, for callers that need finer control than splice / compose offer.
types
Types that appear on the public API surface and may be useful to import directly.

Structs§

Bundle
Output of splice and compose: the generated WAC source, the dep map it references, contract diagnostics, and any tier-1 adapter components splicer wrote to disk. Most callers reach for Bundle::to_wasm to go straight to a composed component.
ComponentInput
One component to feed into compose.
ComposeRequest
Inputs to compose.
SpliceRequest
Inputs to splice.

Functions§

compose
Synthesize a composition from N individual components.
compose_wac
In-process equivalent of wac compose: parse wac, resolve every package reference against wac_deps, and encode the result into wasmparser-validated bytes. wac_deps must cover every package the WAC references — the resolver does not fall back to the filesystem.
format_wac_compose_cmd
Format a wac compose <wac_path> --dep ... shell command line from the wac source path and the per-dependency (package_key, wasm_path) map returned by splice or compose.
splice
Splice middleware into a pre-composed Wasm component.