Using Rust to Create an EDJX Serverless Function

Prerequisites

  1. 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.
  2. Open a terminal instance on your system.

  3. Navigate to the $HOME/ or ~/ directory.

  4. Install the Rust WASM target.

    rustup target add wasm32-unknown-unknown
  5. 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

Build 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