Setup your Rust environment
To be able to run Wasmer inside our Rust application, we will need Rust installed in our system.
The easiest way to get Rust in your system is via Rustup. To get Rustup on Linux and macOS, you can run the following:
1
curl https://sh.rustup.rs -sSf | sh
Copied!
To install Rust on Windows, download and run rustup-init.exe, then follow the onscreen instructions.
To ensure this is installed, let's run the following:
1
rustc -V # This will show Rust version
2
cargo -V # This will show Cargo version
Copied!
If these commands work, Rust is successfully installed!

Start a Rust Project

Now it's time to create a new project and add Wasmer as a dependency:
1
cargo new wasmer-project --bin
Copied!
This should generate two important files for us, Cargo.toml and src/main.rs. The Cargo.toml is a file that describes your project and its dependencies. The src/main.rs is the entry point for your project, and contains the fn main() { .. } that is run when the project is executed.
Now, edit the Cargo.toml file to add wasmer as a dependency:
1
[dependencies]
2
# The Wasmer API
3
wasmer = "2.0"
Copied!
Next, let's take a look at some examples!
Last modified 4mo ago
Copy link