Skip to content

WASM compilation target and multi-language bindings #110

@ds1sqe

Description

@ds1sqe

Context

Part of the Rust core epic (#95, Phase 3). The Rust core currently compiles only as a PyO3 extension. The RFC envisions the same core running in browsers (WASM), edge functions, and other language runtimes via C FFI.

Goal

Compile the Rust core to WASM and provide C FFI for language-agnostic bindings, enabling TypeSchema, ValidationEngine, and QueryCompiler to run outside Python.

Scope

WASM target

  • Conditional compilation: #[cfg(target_arch = "wasm32")] guards for PyO3-free builds
  • wasm-bindgen or wasm-pack setup for browser/Node.js
  • Expose ValidationEngine, QueryCompiler, TypeSchema via JS-friendly API
  • npm package for browser/Node.js consumption
  • Bundle size optimization (tree-shaking unused features)

C FFI

  • cbindgen header generation
  • C-compatible API: type_bridge_* function prefix, opaque handles, error codes
  • Memory management: caller-owned strings, type_bridge_free_* functions

Multi-language bindings (stretch)

  • Node.js via napi-rs or WASM
  • Go via CGo + C FFI
  • Example usage in each target language

Build & CI

  • wasm-pack build in CI
  • WASM artifact upload alongside Python wheels
  • Feature flags: features = ["python", "wasm", "ffi"]

Dependencies

  • Core API stabilization (all Phase 1-2 issues should be settled)

Acceptance criteria

  • wasm-pack build produces a working .wasm + JS glue
  • A minimal JS test validates a type name and compiles a query from the browser
  • C header is generated and a minimal C program links against the library
  • No PyO3 dependency in the WASM/FFI build

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrust-coreRust core integration (Epic #95)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions