Skip to main content

Crate muon_wasm

Crate muon_wasm 

Source
Expand description

A wasm32-unknown-unknown wrapper exposing [muon::parse] to JavaScript.

The muon crate itself is no_std; this thin shim links std only for the allocator that wasm32-unknown-unknown provides, so no wasm-bindgen (or any post-processing tool) is needed — the .wasm is loaded directly.

§ABI

Strings cross the boundary as (ptr, len) into wasm linear memory:

  • muon_alloc(len) -> ptr — reserve len bytes for JS to write UTF-8 into.
  • muon_parse(ptr, len) -> out — parse those bytes; returns a pointer to a length-prefixed result: a little-endian u32 byte length followed by that many bytes of UTF-8 JSON. On success it is the tagged tree dump (muon::Seq::to_json); on failure, {"error":{"offset":N,"kind":"…"}}.
  • muon_free(ptr, len) — release a block obtained from muon_alloc.

Functions§

muon_alloc
Reserve len bytes of linear memory and hand ownership to the caller.
muon_free
Release a block previously returned by muon_alloc (same len).
muon_parse
Parse len UTF-8 bytes at ptr; return a length-prefixed JSON result.