Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust projects — deployment

Three Rust systems projects and the portfolio site that runs all three of them in the browser, in one repository so the site can be deployed from it directly.

Live site: the website/ directory is the deployment target.

Directory What it is Standalone repository
blockchain-rust/ Proof-of-work blockchain — SHA-256 sealing over a canonical length-prefixed encoding, nonce search against a difficulty target, validation that re-derives every hash Blockchain-RUST
redis-client-rust/ Redis client written from the wire protocol up — RESP2/RESP3 codec, stream framing, 40+ typed commands, pipelining, a bounded connection pool Redis-Client-RUST
rusty-cli/ Parallel computation CLI — checked 64-bit kernels, a Rayon work pool, layered configuration RUSTY-CLI
website/ The static site, with every demo running the real crate source compiled to WebAssembly

The three project directories are copies of the standalone repositories above, kept here so the site's WebAssembly bridge can depend on them by path.

Deploying to Vercel

Nothing is compiled at deploy time — the .wasm is committed, and the site has no build step, no framework and no dependencies.

  1. Import this repository in Vercel.
  2. Framework preset: Other.
  3. Leave the build command empty. vercel.json already sets the output directory to website.

vercel.json also pins Content-Type: application/wasm on the module so WebAssembly.instantiateStreaming takes the fast path. If it ever does not, the page falls back to a base64 copy of the module and still works.

Running it locally

cd website
./serve.sh              # http://localhost:8080

The page also opens straight from disk — fetch is blocked by the file:// origin, so it loads the embedded base64 copy of the module instead.

How the site runs the crates

website/wasm/ is a small crate that depends on the three projects as ordinary path dependencies, each built with its native-only features disabled:

blockchain-rust   = { path = "../../blockchain-rust",   default-features = false }
redis-client-rust = { path = "../../redis-client-rust", default-features = false }
rusty-cli         = { path = "../../rusty-cli",         default-features = false }

Turning off default features is what lets them target wasm32-unknown-unknown: it drops Tokio and sockets from the Redis client, Rayon from the CLI, and the system clock from the blockchain. Each crate keeps I/O out of its core specifically so this works.

There is no wasm-bindgen and no toolchain beyond cargo. The module exports four functions and takes JSON:

alloc(len)          -> ptr     reserve a buffer for the request
dispatch(ptr, len)  -> ptr     run it; the result is length-prefixed JSON
free_result(ptr)               release the response
dealloc(ptr, len)              release the request

Rebuilding the WebAssembly

Only needed after changing one of the three crates.

rustup target add wasm32-unknown-unknown
cd website && ./build.sh

On Windows without the Visual Studio Build Tools and Windows SDK, point the script at the GNU toolchain instead:

rustup toolchain install stable-x86_64-pc-windows-gnu
RUST_TOOLCHAIN=stable-x86_64-pc-windows-gnu ./build.sh

Testing

Each project is a standalone crate with its own suite — 132 tests in total.

for p in blockchain-rust redis-client-rust rusty-cli; do
  (cd "$p" && cargo test && cargo clippy --all-targets -- -D warnings \
                        && cargo fmt --all -- --check)
done

License

MIT. See LICENSE.

Releases

Packages

Contributors

Languages