Expand description
trumly-core for the browser. No wasm-bindgen: three plain functions, so the only tool needed is
cargo build --target wasm32-unknown-unknown.
A WASM module can only exchange numbers with JavaScript, so text goes through the module’s
memory: JS asks us to alloc a buffer, copies bytes in, calls check, reads the answer bytes
back out of memory, then calls dealloc on both buffers.
input (JSON): [[“path.md”, “file text”], …]
output (JSON): the check --json document, or {“error”: “…”}
Functions§
- alloc
- Reserve
lenbytes inside the module and return where they are. - check_
json ⚠ - Run
checkover the JSON input at (ptr, len). Returns the output location packed into one u64: high 32 bits = pointer, low 32 bits = length. (wasm32 pointers are 32 bits.) - dealloc⚠
- Give a buffer back.
lenmust be the length passed toalloc(or returned bycheck). - run
- The safe part, separated so it can be tested without any pointers.