Overview
An overview of Rust support in Scale Functions
Scale Functions currently support using Rust as a Guest language.
This means that you can write your Functions in Rust (Guest Support).
Guest Support
A Scale Function written in Rust often looks something like this:
The above example is a simple HTTP Function that responds with "Hello, World!" to any request.
By default, the generated function will be configured to use the HTTP Signature
,
which provides an interface for handling HTTP requests and responses. To learn more about the HTTP Signature
and the
interfaces it provides, you can check out the HTTP Signature Reference. Learn more about Signatures in the Signatures Overview.
Compiling these Functions requires the appropriate toolchain to be installed on your machine.
Installing the Rust Toolchain
To use Rust as the Guest Language, you'll need to install the following:
- The Rust toolchain
- The Cargo package manager
- The wasm32-unknown-unknown build target
The best way to install Rust is to follow the official instructions for your operating system and platform at https://www.rust-lang.org/tools/install.
In general, you'll want to install the rustup
tool, which will allow you to easily install and manage multiple
versions of Rust on your machine. This can be done by running the following command:
You can verify that Rust was installed correctly by running the following command:
The minimum supported version of Rust for use with Scale Functions is 1.67.0
.
You can verify that Cargo was installed correctly by running the following command:
The minimum supported version of Cargo for use with Scale Functions is 1.67.0
.
Next, you'll need to install the wasm32-unknown-unknown
build target. This can be done by running the following
command:
You can verify that the build target was installed correctly by running the following command and verifying that
wasm32-unknown-unknown
is listed in the output:
Last updated on