Help to understand WebAssembly

I am trying to do something as following:

I have a database in my local machine, I build a website, and the users of the website can input something in the web page, which is being listened by the running Rust program. Then the Rust program handle the input and do some calculation process, and return something to the users.

I don't know what is the proper way to do it. I heard WebAssembly a lot, but I found WebAssembly need to be compiled to the webpage, so it seems it cannot access the local database. I also found crate Rocket, which can listen to webpage and do the process. But I also need that each user has a isolated background running program.

What should I do?

WebAssembly won't let you do anything special except run Rust code in the browser. WebAssembly is not a solution to any sort of architectural problem. It's simply another compilation target. If your problem isn't solved by compiling to ARM instead of x86, then compiling to WebAssembly won't help either.

Apart from that, it's unclear specifically what you are trying to achieve. Are you trying to build a client-server system?

1 Like

Yes, I am trying to build a client-server system.

In this case, you'll probably have to create a separate and client applications. These are largely independent – you can write either one in whichever one. Typically, Rust is more useful on the server side (to safeguard correctness of the business logic) than the client side, though.

1 Like

If I need the server run in website, should I use the crate Rocket to handle the user request?

I don't understand what you mean by "server run in website". You can use whichever server-side framework you prefer, all of them can create HTTP request handlers (that is their job).

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.