Skip to main content

Crate lattice_wit

Crate lattice_wit 

Source
Expand description

The canonical plugin API — lattice’s wit/ package — as a crate, so a plugin can depend on a named ABI generation instead of a copied directory (WT.1).

Design: docs/dev/architecture/wit-ownership.md.

WIT is the canonical plugin API, and lattice owns it. Every copy of wit/ in a plugin tree is a cache of this package, never a fork — but until this crate existed nothing said so and nothing enforced it. A plugin got its copy once, at scaffold time, and then it silently drifted: three ABI changes in a day left two installed components unloadable and the editor said nothing at all.

The copy exists for a real reason — wit_bindgen::generate! resolves its path when the macro expands, so the files must be on disk beside the crate being compiled. That is a build-time need, and a build-time need is met by the build:

ⓘ
// a plugin's build.rs
fn main() {
    lattice_wit::write_to("wit").expect("write the lattice API package");
}

wit/ becomes generated output, and which ABI a plugin targets becomes a pinned dependency — which is what it always was.

§Zero dependencies, deliberately

A plugin needs this at build time without building the editor. A crate that pulled in any editor crate would defeat its own purpose. That constraint is also why ABI_FINGERPRINT is an FNV-1a rather than a sha2.

Constants§

ABI_FINGERPRINT
Fingerprint of the embedded package — see the crate docs.

Statics§

FILES
lattice’s wit/ API package, embedded at build time.

Functions§

file_names
Names of the files this package writes.
write_to
Write the embedded package into dir, creating it if needed.