Can a non-IC app written in Rust run in a canister?

Sorry if this sounds like a dumb questions but can an app like this written in Rust for web 2.0 be migrated to the IC?

And if yes, what’s generally involved?

thanks!

now this is Pod racing

I suspect, but need to verify that the main issue is not whether it is written on Rust or any language. The main issue is whether the app can run in WebAssembly, which is the execution environment of the IC and the compilation target of the IC.

But let me ask to see who can give a more intelligent answer.

so it states " It is compiled to WebAssembly, and can run in any Spin environment."

and “Spin is a framework for building and running event-driven microservice applications with WebAssembly (Wasm) components.”

in theory it sounds like it might be able to work right?

so i’m looking into this because i’d like to launch a crypto/blockchain focused news site and obviously want it on the most bleeding edge technology :slight_smile: so if its possible to port something over i’m down to fund a bit of that

1 Like

Great question! you reached the limits of my knowledge. I have asked folks… but sometimes best thing to do is try: have you tried it?

It targets WASI so it most likely depends on things that aren’t available on the IC.

We target wasm32-unknown-unknown

3 Likes

well darn. thanks for the answer though!

I’ve done quite a bit of getting things to work on the IC that weren’t intended to, and in general it can be done if there are abstractions over certain things.

Even if there aren’t, you can probably create a fork and introduce them.

Also, after taking a quick look at Spin, it looks like it relies on placing compiled Wasm modules in separate files and tying them all together with a manifest file that links every module to its URL path.

There is no concept of file on the IC, so at the very least you would need to rebuild everything to be a single Wasm module, with the manifest file replaced by #[export_name] Rust attributes.

3 Likes