logic-mesh

Crates.iologic-mesh
lib.rslogic-mesh
version0.1.10
sourcesrc
created_at2023-06-27 18:37:22.750789
updated_at2024-03-20 17:48:32.675552
descriptionControl logic engine using event based and reactive blocks written in Rust.
homepage
repositoryhttps://github.com/rracariu/logic-mesh
max_upload_size
id901537
size509,269
Radu Racariu (rracariu)

documentation

README

GitHub CI License crates.io npm

Logic Mesh

A logic engine, written in Rust, that is fully async, dynamic, and reactive.

Example program

Possible applications

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.

Features

  • Fully async and reactive
  • WASM support
  • Uses Tokio for async runtime
  • The API is simple enough to be used in a variety of applications
  • A low code editor is included as an example of how Logic Mesh can be used
  • A growing library of built-in blocks
  • Extensible with custom blocks, either in Rust or JavaScript when running in a WASM environment

UI Editor

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.

NPM Package

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.

Examples

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;
Commit count: 230

cargo fmt