/wasm-sdlt

UK Stamp Duty Land Tax calcultor - WASM

Primary LanguageHTML

Rust

Build a simple web application using Rust and Web Assembly.

Create a Rust Project

cargo new tax-calc-wasm

cd tax-calc-wasm

Add wasm_bindgen crate

cargo add wasm-bindgen

Edit Cargo.toml and add:

[lib]
crate-type = ["cdylib", "rlib"]

Step 2: Writing the Rust Code

Edit src/lib.rs to implement the tax calculation logic:

// Importing wasm_bindgen crate to enable communication between JavaScript and Rust
use wasm_bindgen::prelude::*;

// Define the function that will be exposed to JavaScript
#[wasm_bindgen]
pub fn xyz () {
}

Step 3: Building the Project

Build the project using wasm-pack:

wasm-pack build --target web

Step 4: Setting Up the Web Environment

Create an index.html file in the tax-calculator-wasm directory

Step 5: Serving the Project

To serve the project, you need a simple web server.

http-server

http-server . Navigate to http://localhost:8000 in your web browser to see the tax calculator in action.