Safe Filesystems and Emscripten

Emscripten is a compiler tool which compiles many different languages to either JavaScript or Web Assembly (including for use in a web browser).

This means it can be used to pull together applications or libraries written in different languages, allowing parts to written in Rust to be combined with other languages: “Rust has Emscripten integration, with the wasm32-unknown-emscripten and asmjs-unknown-emscripten targets” (link)

Example

My use case is to be able to write new code in Rust along with wasm-git for git functionality, sharing an in browser filesystem, and ultimately working on the Safe filesystem. I’m currently investigating the feasibility of this as a way of moving the p2p Git Portal (github) away from dependence on Golang libraries.

This topic is for discussion of the feasibility of creating an Emscripten filesystem on top of the Safe filesystem.

At this point I don’t have plans to work on this but would like to discuss feasibility of Emscripten filesystem support while I build something on the assumption it can or likely will be done! Let me know if it is something you’d like to work on and I may be tempted to help.

Emscripten Filesystems

The Emscripten filesystem API is POSIX like and allows for mounting other filesystems for access using the standard APIs of your source language (ultimately libc like). For free you get the non-persistent filesystem emulation, and several mountable options which include persistence (links below).

So I expect it will be feasible to provide a Safe Filesystem which can be mounted by the Emscripten application, which would be accessible to the application and all its libraries no matter their source language.

I guess this would also be a step towards building cross-platform applications based on compiling the Safe APIs to web assembly, so this is not just a niche use case.

Links


This post is a Wiki, so feel free to add more links or useful resources.

1 Like