Set up Rust for Edgecompute
The Legacy Rust SDK is based on the fastedge crate, Gcore's original Rust library for Edgecompute HTTP applications. Most existing Edgecompute applications written in Rust use this SDK. Use this setup when working with existing applications built on the fastedge crate or when maintaining code that still targets wasm32-wasip1.
The crate provides the #[fastedge::http] entry-point macro together with APIs for environment variables, secrets, key-value storage, dictionary access, and cache integration.
Rust and Cargo are required. On Windows, also install Visual Studio Build Tools with the Desktop development with C++ workload.
For new applications, the Modern Rust SDK (wstd, wasm32-wasip2) is the recommended direction — it uses the WASI-HTTP standard and reduces dependency on Gcore-specific tooling.
Add the WebAssembly target
The Legacy SDK compiles to wasm32-wasip1. Add the target once — it applies to all future builds:
rustup target add wasm32-wasip1
Configure a project
Edgecompute applications compile to WebAssembly libraries rather than standalone executables. Two changes from the Cargo defaults are needed: the output type must be cdylib, and the fastedge crate must be listed as a dependency.
-
Create the library crate:
cargo new --lib my-app cd my-app -
Replace the contents of
Cargo.toml:[package] name = "my_app" version = "0.1.0" edition = "2021" [lib] crate-type = ["cdylib"] [dependencies] fastedge = "0.4" anyhow = "1.0"crate-type = ["cdylib"]changes the output to a format the Edgecompute runtime can load.fastedge = "0.4"provides the entry-point macro and access to Edgecompute-specific APIs.anyhowis used for error handling in the verification example below.
Verify the toolchain
A minimal handler is enough to confirm the toolchain produces a valid WebAssembly binary. Replace src/lib.rs:
use fastedge::body::Body;
use fastedge::http::{Request, Response, StatusCode, Error};
#[fastedge::http]
fn main(_req: Request<Body>) -> Result<Response<Body>, Error> {
Response::builder()
.status(StatusCode::OK)
.body(Body::from("OK"))
}
Build it:
cargo build --release --target wasm32-wasip1
The first build downloads dependencies and takes one to two minutes. When it completes without errors, the toolchain is ready — the compiled binary is at ./target/wasm32-wasip1/release/my_app.wasm. That file can be uploaded to Edgecompute directly or used as the starting point for the next tutorial.