What Will I Learn?
- You will learn how to build a full Rust Library for Wasm Compilation
- You will learn how to make a markdown parser in Rust
- You will learn how to make a multi-file library for WASM
- You will learn about WASM's performance advantages and the extensibility of Rust
- You will learn about public and private functions and how they interact with Wasm
- You will learn how to automate many parts of the build pipeline for Rust to WASM Compilation
- Visual Studio Code or any other Text Editor with Rust language plugins
- The Rustup command line tool and the nightly Rust compiler
- Some basic understanding of Rust
- A fair amount of knowledge on web technologies and how they work
Resources for Rust
- Rust Website: https://www.rust-lang.org/
- Web Assembly Website: https://webassembly.org/
- Awesome Rust: https://github.com/rust-unofficial/awesome-rust
- Wasm Bindgen Repo: https://github.com/rustwasm/wasm-bindgen
- WASM Logo: https://webassembly.org/
Outline and Overview
Above is a picture of the TypeScript Typings that were generated from the
Using Functional Design Patterns for the Sake of Extensibility
struct to create an Object which contains our parser. This makes our code much more composable which in turn helps reduce the cost of running these functions.
Here you can see the
consume_while function which works to parse the text of our application under specific conditions. By using a generic type, a first class closure and a functional guard, we are able to make this function much more general which helps with the extensibility of the code. In different the different methods of our library, we use this function with a few simple one line closures to specify the behavior of our code.
Automating the Build Process using Webpack and Yarn
In the last video, we talked about the main developer pipeline which is used to convert Rust to WASM. In this application, we take that a step further by adding a script to the
package.json file. This script gives us the ability to compile the Rust library into WASM. We also are able to automate the
Here you can see the
build-debug command that was written into the
package.json file of our project. We are easily able to compose the two commands together to automate the process of building the WASM from the Rust code. With Webpack we can take this further and add watchers which will automatically compile from Rust to WASM while the developer server is running.
The source code for this project can be found here