Cross-Compiling a Rust Library with DuckDB for WebAssembly (WASM)

WASM apps normally run in the web browser where, for security reasons, there are restrictions on what kind of I/O (file, device and network) access your program has.

As a result, much of the Rust standard library doesn't compile for WASM (std::net, std::fs and the like). I'm not familiar with DuckDB, but drivers for database engines in particular are likely to require I/O ops from the standard library that are not supported in the WASM environment, which would cause your compilation to fail.

Now it appears that DuckDB have created a special version of their DB engine that does run as a WASM app and can be controlled via a TypeScript language API. There don't appear to be Rust bindings for this WASM-based engine. Although in theory one could be written, it appears you would have to do that yourself.

1 Like