Glossary

Technical terms used in Rust + WebAssembly development

Crate

Rust

A 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

Rust

An interface that defines shared behavior. Types implement traits to provide specific functionality. Similar to interfaces in TypeScript or Java.

Ownership

Rust

Rust'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

Rust

Temporarily 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

Rust

The 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

Rust

An anonymous function that can capture variables from its surrounding scope. In Wasm, closures are used as JavaScript callbacks via Closure::wrap.

Macro

Rust

Code 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

Rust

The region of code where a variable is valid and accessible. In Rust, variables are dropped (deallocated) when they go out of scope.

Heap

Rust

A 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

Rust

Basic 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

WebAssembly

The 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

WebAssembly

A 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

WebAssembly

Auto-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

WebAssembly

The build tool for Rust/Wasm projects. Compiles Rust to .wasm, runs wasm-bindgen, generates TypeScript types, and creates an npm-ready package.

JsValue

WebAssembly

A 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

WebAssembly

A 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 APIs

A 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 APIs

Code that connects two different systems or languages. In Rust/Wasm, bindings let Rust call JavaScript APIs and vice versa.

Feature (Cargo)

Web APIs

Cargo'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 APIs

A 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 APIs

Cross-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

Security

A cryptographic hash function that produces a fixed 256-bit (32-byte) output from any input. Deterministic, one-way, and collision-resistant.

Salt

Security

A 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

Security

A precomputed lookup table of hash values used to reverse hashes back to their original input. Defeated by using salts.

Key Derivation Function

Security

A 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

General

Converting 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

General

A 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

General

Encode: 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

General

A 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.