1 of 11

wasm-primer

Hunter Trujillo

@cryptoquick (Twitter, Telegram, GitHub)

@cryptoquick@bitcoinhackers.org

https://github.com/diba-io/bitmask-core

2 of 11

rust

  • performance
    • shared memory
    • parallelism
    • micro-optimizations
  • ergonomics
  • correctness
  • maintainability
  • versatility

3 of 11

wasm

  • bytecode
  • sandboxed
  • run in JIT runtimes like wasmtime
  • occasionally compiled AOT
  • v8 contexts

4 of 11

tools

  • wasm-bindgen
    • JsValue
    • futures, async, …promises?
  • wasm-pack
  • trunk

5 of 11

things to be aware of

  • conditional compilation
  • traits / impl
  • bounds / generics
  • from / into
  • match statements
  • destructuring
  • enums / structs
  • implicit return / semicolons

6 of 11

how to learn rust

  • docs.rs
  • github examples
  • github issues
  • RTFS
  • *referencing* the book
  • learn how to read errors

7 of 11

exercise

8 of 11

answer

9 of 11

how to write rust

  • vs code
  • rust-analyzer (not RLS)
  • cargo-clippy
  • format on save
  • run clippy as formatter
  • you now have Rust as your co-pilot

10 of 11

helpful crates

  • serde
  • chrono
  • anyhow
  • tokio
  • gloo
  • look at similar crates and their Cargo.toml
  • crates.io
  • lib.rs

11 of 11

rust will kick your ass

  • but it's for a good reason

join the Rust in Bitcoin telegram group: https://t.me/rust_in_bitcoin