|
1 | | -## Project Overview |
2 | | - |
3 | | -This project, named "simu," is a digital logic circuit simulator. It provides a graphical user interface (GUI) where users can build and simulate logic circuits. The application is built with Rust and uses the `egui` and `eframe` libraries for its GUI. It is designed to be cross-platform and can be compiled for both native and web environments. |
4 | | - |
5 | | -The simulator allows users to: |
6 | | - |
7 | | -* Drag and drop logic gates (AND, NAND, OR, NOR, XOR, XNOR) and power sources onto a canvas. |
8 | | -* Connect these components using wires. |
9 | | -* Toggle power sources to observe the flow of electricity through the circuit. |
10 | | -* A debug panel is available to inspect the internal state of the simulation. |
11 | | - |
12 | | - |
13 | | -Main code is in ./src/app.rs |
14 | | - |
15 | | -## Building and Running |
16 | | - |
17 | | -### Native |
18 | | - |
19 | | -To build and run the native application, use the following command: |
20 | | - |
21 | | -```bash |
22 | | -cargo run |
23 | | -``` |
24 | | - |
25 | | -### Web |
26 | | - |
27 | | -The web application is built using [Trunk](https://trunkrs.dev/). To build and serve the web application locally, use the following command: |
28 | | - |
29 | | -```bash |
30 | | -trunk serve |
31 | | -``` |
32 | | - |
33 | | -This will build the application and start a local server. You can then access the application in your web browser at the address provided by Trunk (usually `http://127.0.0.1:8080`). |
34 | | - |
35 | | -### Checking the Code |
36 | | - |
37 | | -The project includes a `check.sh` script that runs a series of checks to ensure code quality. To run these checks, execute the following command: |
38 | | - |
39 | | -```bash |
40 | | -./check.sh |
41 | | -``` |
42 | | - |
43 | | -This script will: |
44 | | - |
45 | | -* Check for compilation errors (`cargo check`). |
46 | | -* Check for formatting issues (`cargo fmt`). |
47 | | -* Lint the code with Clippy (`cargo clippy`). |
48 | | -* Run tests (`cargo test`). |
49 | | -* Build the web application (`trunk build`). |
50 | | - |
51 | | -## Development Conventions |
52 | | - |
53 | | -* **GUI:** The application uses the `egui` and `eframe` libraries for its GUI. All UI components and interactions are implemented using these libraries. |
54 | | -* **State Management:** The application state is managed in the `App` struct in `src/app.rs`. This includes the state of all circuit components, user interactions, and the simulation itself. |
55 | | -* **Simulation:** The core simulation logic is implemented in the `recompute_current` and `eval_instance` methods in `src/app.rs`. The simulation is re-run whenever the circuit is modified. |
56 | | -* **Cross-Platform:** The application is designed to be cross-platform. The `src/main.rs` file contains separate entry points for the native and web builds. |
57 | | -* run `./check.sh` after your changes and ensure there are no warnings or errors. |
58 | | - ``` |
| 1 | +# Simu - Digital Logic Circuit Simulator |
| 2 | + |
| 3 | +**Build Commands:** |
| 4 | +- Native: `cargo run` |
| 5 | +- Web: `trunk serve` |
| 6 | +- All checks: `./check.sh` (includes cargo check/fmt/clippy/test + trunk build) |
| 7 | + |
| 8 | +**Architecture:** |
| 9 | +- Rust 2024 edition with egui/eframe GUI framework |
| 10 | +- Cross-platform (native + WASM web builds) |
| 11 | +- Core modules: app.rs (main logic), connection_manager, custom_circuit, drag, save_load |
| 12 | +- Uses slotmap for entity management, serde for persistence |
| 13 | + |
| 14 | +**Code Style:** |
| 15 | +- Strict linting: unsafe_code=deny, extensive clippy rules enabled |
| 16 | +- No unsafe code, warn on trivial issues |
| 17 | +- Formatting: `cargo fmt --all -- --check` |
| 18 | +- Imports: std first, then external crates, then local modules |
| 19 | +- Naming: snake_case functions/variables, PascalCase types, SCREAMING_SNAKE_CASE constants |
| 20 | +- Error handling: Result/Option types preferred over panics |
| 21 | +- Run `./check.sh` after changes to ensure no warnings/errors |
0 commit comments