Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cvyl/wasm-counter
Simple WebAssembly counter implemented in Rust. Use this project to learn the basics of WebAssembly and Rust integration.
https://github.com/cvyl/wasm-counter
rust rust-wasm rust-webassembly wasm wasm-bindgen wasm-example webassembly webassembly-demo webassembly-tutorial
Last synced: about 2 months ago
JSON representation
Simple WebAssembly counter implemented in Rust. Use this project to learn the basics of WebAssembly and Rust integration.
- Host: GitHub
- URL: https://github.com/cvyl/wasm-counter
- Owner: cvyl
- License: mit
- Created: 2023-11-11T19:01:24.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-11T20:35:25.000Z (about 1 year ago)
- Last Synced: 2024-05-02T05:13:01.779Z (9 months ago)
- Topics: rust, rust-wasm, rust-webassembly, wasm, wasm-bindgen, wasm-example, webassembly, webassembly-demo, webassembly-tutorial
- Language: JavaScript
- Homepage: https://dev.lgbt.sh/wasm-counter/
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Rust WebAssembly Project](https://github.com/ly-nld/wasm-counter/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/ly-nld/wasm-counter/actions/workflows/main.yml)
[![pages-build-deployment](https://github.com/ly-nld/wasm-counter/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/ly-nld/wasm-counter/actions/workflows/pages/pages-build-deployment)# WebAssembly Counter Project
This project demonstrates a simple WebAssembly program written in Rust. The program implements a counter that can be incremented and decremented.
## Prerequisites
Before you begin, ensure you have the following installed:
- [Rust](https://www.rust-lang.org/learn/get-started)
- [Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html)
- [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind/setup.html)## Building and Running
1. Clone the repository:
```bash
git clone https://github.com/ly-nld/wasm-counter.git
cd wasm-counter
```2. Build the Rust project:
```bash
cargo build --target wasm32-unknown-unknown
```3. Generate JavaScript bindings:
```bash
wasm-bindgen target/wasm32-unknown-unknown/debug/wasm_counter.wasm --out-dir www --web
```4. Serve the project using a local server:
```bash
# You can use http-server or any other server of your choice, for example, python -m http.server
npx http-server www
```5. Open your browser and navigate to [http://localhost:8080](http://localhost:8080) (or the port used by your local server).
## Usage
- The webpage will display the current counter value.
- Click the "Increment" button to increase the counter.
- Click the "Decrement" button to decrease the counter.## License
This project is licensed under the [MIT License](LICENSE).