Crates.io | logic-mesh |
lib.rs | logic-mesh |
version | 0.1.10 |
source | src |
created_at | 2023-06-27 18:37:22.750789 |
updated_at | 2024-03-20 17:48:32.675552 |
description | Control logic engine using event based and reactive blocks written in Rust. |
homepage | |
repository | https://github.com/rracariu/logic-mesh |
max_upload_size | |
id | 901537 |
size | 509,269 |
A logic engine, written in Rust, that is fully async, dynamic, and reactive.
Logic Mesh started as a hardware control engine, but the scope expanded to anything that requires a reactive and dynamic evaluation engine. It is designed to be used in a variety of applications, from hardware controls, games to web servers. It is designed to be fast, efficient, and easy to use.
The included WASM support allows it to be used in web applications, with the option to use the same codebase for both the frontend and backend.
There is a sample low code editor that is built on top of Logic Mesh, which can be found here. It serves as an example of how Logic Mesh can be used, and as a simple way to experiment with the Logic Mesh engine.
The engine is also available as an NPM package, which can be found here. The NPM package is a thin wrapper around the WASM package, and it can be used in a Node.js environment.
The following examples are written in Rust.
// Init a Add block
let mut add1 = Add::new();
// Init a SineWave block
let mut sine1 = SineWave::new();
// Se the amplitude and frequency of the sine wave
sine1.amplitude.val = Some(3.into());
sine1.freq.val = Some(200.into());
// Connect the output of the sine wave to the first input of the add block
connect_output(&mut sine1.out, add1.inputs_mut()[0]).expect("Connected");
// Init another SineWave block
let mut sine2 = SineWave::new();
sine2.amplitude.val = Some(7.into());
sine2.freq.val = Some(400.into());
// Connect the output of the sine wave to the second input of the add block
sine2
.connect_output("out", add1.inputs_mut()[1])
.expect("Connected");
// Init a single threaded engine
let mut engine = SingleThreadedEngine::new();
// Schedule the blocks to be run
engine.schedule(add1);
engine.schedule(sine1);
engine.schedule(sine2);
// Run the engine
engine.run().await;