Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Latest commit

 

History

History
171 lines (122 loc) · 3.92 KB

README.md

File metadata and controls

171 lines (122 loc) · 3.92 KB

Noosphere Rust

License Tests

The core of all Noosphere-related packages in this repository is represented by the collection of Rust packages found in this directory. If you are writing a program in Rust and you wish to implement Noosphere within that program, you should be able to install the packages found here directly from cargo on the command line: https://crates.io/keywords/noosphere

Most other language implementations of Noosphere bind to this Rust implementation internally, so making changes to Noosphere for a package targetting another language will most likely involve writing some Rust.

Rust Components

flowchart TD

noosphere((Noosphere))
cli((CLI))

noosphere --> api
noosphere --> core
noosphere --> storage
noosphere --> ipfs
noosphere --> sphere
noosphere -. wasm .-> into
noosphere -. dev .-> sphere

api --> core
api --> storage

cli --> api
cli --> core
cli --> gateway
cli --> ipfs
cli --> noosphere
cli --> storage
cli --> sphere

collections --> storage

core --> collections
core --> storage

gateway --> api
gateway --> core
gateway --> ipfs
gateway --> noosphere
gateway --> ns
gateway --> sphere
gateway --> storage

into --> core
into --> storage
into --> sphere

ipfs -. !wasm .-> core
ipfs --> storage

ns --> storage
ns --> core
ns --> noosphere

sphere --> core
sphere --> storage
sphere --> api

Loading

Environment Setup

Platform Packages

Several platform-specific dependencies must be installed on your platform, and are needed to build Noosphere:

Additional dependencies needed to build the WASM artifact:

Linux (apt)

sudo apt install libssl-dev protobuf-compiler cmake jq binaryen

MacOS (homebrew)

brew install openssl protobuf cmake jq binaryen

Rust

Importantly: you need an up-to-date Rust toolchain. The most reliable way to ensure you have this is to follow the instructions on https://rustup.rs/

Minimum supported rustc version: 1.70.0

If you wish to compile for targets other than your local platform target, you can use rustup to get other targets easily. For example:

rustup target add wasm32-unknown-unknown

If you would like install the full set of targets used by this project at this time, you can run the following:

rustup target install \
  wasm32-unknown-unknown \
  aarch64-apple-ios \
  x86_64-apple-ios \
  aarch64-apple-ios-sim \
  x86_64-apple-darwin \
  aarch64-apple-darwin

Web Assembly

Finally, you should install a webdriver in order to run headless browser tests e.g., ChromeDriver

And then run this one-liner from the repository root to ensure you have the correct version of wasm-bindgen-cli:

cargo install toml-cli && cargo install wasm-bindgen-cli --vers `toml get ./Cargo.lock . | jq '.package | map(select(.name == "wasm-bindgen"))[0].version' | xargs echo`

Build Examples

Build the project for your platform:

cargo build

Run local platform tests:

cargo test

Run browser tests in headless Chrome:

# Change /path/to/chromedriver as appropriate for your environment
CHROMEDRIVER=/path/to/chromedriver cargo test --target wasm32-unknown-unknown

Errata

Rust analyzer may have issues expanding #[async_trait]: