Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WebAssembly development

ACORN’s portable Rust surface can be checked for the wasm32-unknown-unknown target. This is currently a portability build for contributors, not a published JavaScript or browser package.

Important

make wasm runs cargo check. It verifies that the portable feature path compiles, but it does not link a .wasm artifact or generate JavaScript bindings.

Installation

Install the Rust toolchain and add the WASM target:

rustup target add wasm32-unknown-unknown

Clone the ACORN repository, then run the check from its root:

make wasm

The equivalent Cargo command is:

cargo check -p acorn-lib --no-default-features --features wasm --target wasm32-unknown-unknown

Rust projects that compile to WASM can select the same ACORN surface:

cargo add acorn-lib --no-default-features --features wasm

Currently available functionality

The WASM build exposes Rust APIs that operate on supplied in-memory values. It currently includes:

CapabilityAvailable functionality
Research metadataResearchActivity and its supporting metadata, section, linked-data, and media types
Metadata standardsSerde-compatible CFF, DataCite, DCAT, Dublin Core, Huwise, Invenio, and text models; in-memory schema crosswalk contracts and conversions
Persistent identifiersARK, DOI, ISBN, ISNI, ORCID, RAiD, ROR, and patent parsing, recognition, normalization, component access, and checksum validation where the identifier defines one
ValidationResearch schema validation plus helpers for identifiers, dates and timestamps, URLs, semantic versions, geographic coordinates and polygons, language and country codes, phone numbers, and media extensions
Hardware metadataArchitecture, accelerator, processor, memory, sensor, topology, vendor, and computing-resource models
Portable domain APIsLocation, Repository, Scheme, Release, AcornError, and AcornResult
Portable utilitiesMIME and file-extension detection, Crockford Base32, constant-time byte comparison, glob matching, regex-to-glob conversion, frontmatter splitting, semantic versions, byte formatting, and string normalization
Reference dataCompile-time vocabularies used by portable schema and validation code

Schema types implement their normal Serde, JSON Schema, and validation traits in this configuration. Callers provide the strings, bytes, or already-deserialized values; ACORN does not fetch or read them in the WASM build.

For example, a Rust component compiled to WASM can use ACORN’s identifier validation directly:

#![allow(unused)]
fn main() {
use acorn::schema::validate::{is_arxiv, is_doi, is_isni, is_orcid, is_ror};

assert!(is_doi("10.11578/dc.20250604.1").is_ok());
assert!(is_arxiv("arXiv:2106.09685").is_ok());
assert!(is_isni("https://isni.org/isni/0000000492299539").is_ok());
assert!(is_orcid("https://orcid.org/0000-0002-2057-9115").is_ok());
assert!(is_ror("https://ror.org/01qz5mb56").is_ok());
}

What the check covers

The current wasm feature selects allocation-capable APIs without enabling ACORN’s native filesystem, process, terminal presentation, database, or network services. The check protects that dependency boundary on a browser-compatible compilation target.

The check does not currently provide:

  • wasm-bindgen JavaScript bindings
  • an npm package
  • browser HTTP or storage adapters
  • a supported browser application entry point
  • native file or URL reads and writes
  • analyzer, document conversion, database, process, download, or doctor services
  • std-only agent definitions and embedded agent assets

Those capabilities are planned for a dedicated acorn-wasm adapter crate. Portable crates will remain independent of browser-specific dependencies, and acorn-wasm will compose supported ACORN services with browser implementations.

macOS sandbox warnings

Restricted macOS environments may report that xcrun could not create a cache file while locating MacOSX.sdk. This is a host toolchain warning rather than a WASM compilation failure. If Cargo prints Finished and the command exits successfully, the portability check passed.

Maintainer references

The public guide documents supported developer behavior. Implementation status and architectural decisions are tracked in the internal WASM feature path and no-std/WASM CI plan.