Glossary
Technical terms used in Rust + WebAssembly development
Crate
RustA Rust package or library. Crates are published to crates.io and added to your project via Cargo.toml. Examples: wasm-bindgen, web-sys, sha2.
Trait
RustAn interface that defines shared behavior. Types implement traits to provide specific functionality. Similar to interfaces in TypeScript or Java.
Ownership
RustRust's system for memory management without a garbage collector. Each value has exactly one owner, and the value is dropped when the owner goes out of scope.
Borrowing
RustTemporarily accessing data without taking ownership. &T is an immutable borrow (read-only), &mut T is a mutable borrow (read-write). Prevents data races at compile time.
Lifetime
RustThe scope for which a reference is valid. Rust uses lifetimes to ensure references don't outlive the data they point to. Annotated with 'a syntax.
Closure
RustAn anonymous function that can capture variables from its surrounding scope. In Wasm, closures are used as JavaScript callbacks via Closure::wrap.
Macro
RustCode that generates code at compile time. Rust macros end with ! (e.g., println!, format!, vec!). They can accept variable numbers of arguments unlike regular functions.
Scope
RustThe region of code where a variable is valid and accessible. In Rust, variables are dropped (deallocated) when they go out of scope.
Heap
RustA region of memory for dynamically allocated data. String, Vec, and Box store data on the heap. Slower to allocate than the stack but flexible in size.
Primitive
RustBasic data types built into the language: integers (i32, u64), floats (f32, f64), bool, and char. These pass directly through the Wasm boundary at zero cost.
wasm-bindgen
WebAssemblyThe tool and library that bridges Rust and JavaScript. It generates glue code for type conversion, function exports/imports, and struct-to-class mapping.
Linear Memory
WebAssemblyA contiguous block of bytes that Wasm uses as its memory space. JavaScript can read/write to it via ArrayBuffer views. All Wasm data (strings, arrays, structs) lives here.
Glue Code
WebAssemblyAuto-generated JavaScript code that handles type conversion between JS and Wasm. Created by wasm-pack/wasm-bindgen. The .js file in the pkg/ output.
wasm-pack
WebAssemblyThe build tool for Rust/Wasm projects. Compiles Rust to .wasm, runs wasm-bindgen, generates TypeScript types, and creates an npm-ready package.
JsValue
WebAssemblyA Rust type that represents any JavaScript value. Used as a catch-all when you don't know the specific JS type, or for error handling in Result<T, JsValue>.
cdylib
WebAssemblyA Cargo crate type that produces a C-compatible dynamic library. Required for Wasm output — tells the compiler to create a standalone binary without Rust metadata.
web-sys
Web APIsA Rust crate providing bindings for all Web APIs (DOM, Canvas, Fetch, etc.). Auto-generated from WebIDL specs. Each API is enabled as a Cargo feature to keep binaries small.
Binding
Web APIsCode that connects two different systems or languages. In Rust/Wasm, bindings let Rust call JavaScript APIs and vice versa.
Feature (Cargo)
Web APIsCargo's conditional compilation system. In web-sys, each API (Window, Document, etc.) is a feature you opt into. Only enabled features are compiled, reducing binary size.
Callback
Web APIsA function passed as an argument to be called later, typically in response to an event. In Wasm, Rust closures become JS callbacks via Closure::wrap.
CORS
Web APIsCross-Origin Resource Sharing. A browser security policy that restricts HTTP requests between different domains. Wasm modules follow the same CORS rules as the hosting page.
SHA-256
SecurityA cryptographic hash function that produces a fixed 256-bit (32-byte) output from any input. Deterministic, one-way, and collision-resistant.
Salt
SecurityA random value added to input before hashing to prevent rainbow table attacks. Each input gets a unique salt, so identical inputs produce different hashes.
Rainbow Table
SecurityA precomputed lookup table of hash values used to reverse hashes back to their original input. Defeated by using salts.
Key Derivation Function
SecurityA function that derives cryptographic keys from passwords (e.g., bcrypt, argon2, scrypt). Intentionally slow to resist brute-force attacks. Use instead of SHA-256 for passwords.
Serialization
GeneralConverting data structures into a format that can be transferred or stored (e.g., JSON, binary). In Wasm, minimizing serialization between Rust and JS is key to performance.
Pointer
GeneralA value that holds the memory address of data. In Wasm, exported structs are passed to JS as pointers into linear memory — the data itself is not copied.
Encode / Decode
GeneralEncode: convert data to a specific format (e.g., string to UTF-8 bytes). Decode: convert it back. Wasm string passing involves encoding JS strings (UTF-16) to Rust (UTF-8) and back.
Quadtree
GeneralA tree data structure that recursively divides 2D space into four quadrants. Used to efficiently find nearby objects (e.g., particle collision detection) without checking every pair.