Go to file
2023-11-19 18:12:00 +00:00
qstart install rust and template 2023-11-19 18:12:00 +00:00
.gitignore install rustup 2023-11-19 17:25:30 +00:00
LICENSE Initial commit 2023-11-19 17:46:03 +01:00
README.org install rust and template 2023-11-19 18:12:00 +00:00

Rust Quickstart

#+date:[2023-11-19 Sun]

Org shortcuts

Feetnotes1

create footnote
C-c C-x f
jump to the footnote ref
C-c C-c

Instaling Rust

Looking at the get-started doc, let's use rustup

  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Checking if the install went ok

  rustup --version
  rustup upgrade
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.74.0 (79e9716c9 2023-11-13)`
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: checking for self-update

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.74.0 (79e9716c9 2023-11-13)

info: cleaning up downloads & tmp directories

Ensure cargo, the package manager is also installed

  cargo --version
cargo 1.74.0 (ecb9851af 2023-10-18)

Rust mode for emacs

Install Spin

This has been done already in a previous tut.

  spin -V
spin 2.0.1 (1d72f1c 2023-11-10)

Install Templates for Rust

This has also been done in a previous tut.

  spin template list
+------------------------------------------------------------------------+
| Name                Description                                        |
+========================================================================+
| http-c              HTTP request handler using C and the Zig toolchain |
| http-empty          HTTP application with no components                |
| http-go             HTTP request handler using (Tiny)Go                |
| http-grain          HTTP request handler using Grain                   |
| http-js             HTTP request handler using Javascript              |
| http-php            HTTP request handler using PHP                     |
| http-rust           HTTP request handler using Rust                    |
| http-swift          HTTP request handler using SwiftWasm               |
| http-ts             HTTP request handler using Typescript              |
| http-zig            HTTP request handler using Zig                     |
| redirect            Redirects a HTTP route                             |
| redis-go            Redis message handler using (Tiny)Go               |
| redis-rust          Redis message handler using Rust                   |
| static-fileserver   Serves static files from an asset directory        |
+------------------------------------------------------------------------+

Installing Wasm

We need additional tools to support Wasm.

  rustup target add wasm32-wasi
info: downloading component 'rust-std' for 'wasm32-wasi'
info: installing component 'rust-std' for 'wasm32-wasi'
 17.7 MiB /  17.7 MiB (100 %)  13.8 MiB/s in  1s ETA:  0s

Create the first application

We use spin new and select the rust template http-rust

  spin new -t http-rust qstart
Description []: a quick hello world
Description: a quick hello world
HTTP path [/...]:
HTTP path: /...
  tree qstart/
qstart/
├── Cargo.toml
├── spin.toml
└── src
    └── lib.rs

2 directories, 3 files

The manifest file is spin.toml

  spin_manifest_version = 2

  [application]
  name = "qstart"
  version = "0.1.0"
  authors = ["HaQadosch <redacted>"]
  description = "a quick hello world"

  [[trigger.http]]
  route = "/..."
  component = "qstart"

  [component.qstart]
  source = "target/wasm32-wasi/release/qstart.wasm"
  allowed_outbound_hosts = []
  [component.qstart.build]
  command = "cargo build --target wasm32-wasi --release"
  watch = ["src/**/*.rs", "Cargo.toml"]