Using Rust to Create an EdjFunction
Prerequisites
-
Download the latest version of Rust.
Rust requires a C linker to be present on the system. On most Linux distributions, you need to have the gcc package installed. -
Open a terminal instance on your system.
-
Navigate to the
$HOME/
or~/
directory. -
Install the Rust WASM target.
rustup target add wasm32-unknown-unknown
-
Clone the EDJX Rust Example code repo repository from GitHub to your environment.
This repository contains samples to help you build Rust serverless functions. The functions can then be built and deployed to the EDJX peer-to-peer network using the EDJX Console, CLI, or VS Code Extension.
Create a Function
-
Console - Create Function
-
CLI - function init command
-
VS Code - Add a Function
Build a Function
-
Console - Create Function
-
CLI - function build command
-
VS Code - Build a Function
See also Add a Function and Deploy a Function.
By default, the .wasm file is built and saved under the <function-name>/target/wasm32-unknown-unknown/release
directory with the following file structure.
Project Directory Name
|-- src |-- lib.rs |-- serverless-function.rs |-- target |-- wasm32-unknown-unknown |-- release |-- <function>.wasm |-- Cargo.lock |-- Cargo.toml |-- edjconfig.yaml |-- LICENSE |-- README.md
Deploy a Function
-
Console - Create an EdjFunction
-
CLI - function deploy command
-
VS Code - Deploy a Function