#logic #reactive #control #low-code #events

nightly logic-mesh

使用基于事件和响应式块的Rust编写的控制逻辑引擎

11个版本

0.1.10 2024年3月20日
0.1.9 2024年2月1日
0.1.8 2024年1月10日
0.1.5 2023年12月23日
0.1.1 2023年6月28日

#144 in WebAssembly

Download history 4/week @ 2024-07-02 88/week @ 2024-07-23 40/week @ 2024-07-30

128 每月下载量

BSD-3-Clause

300KB
7.5K SLoC

GitHub CI License crates.io npm

Logic Mesh

一个完全异步、动态和响应式的Rust编写的逻辑引擎。

Example program

可能的用途

Logic Mesh最初是一个硬件控制引擎,但其范围扩展到任何需要响应式和动态评估引擎的应用。它设计用于在各种应用程序中使用,从硬件控制、游戏到Web服务器。它设计用于快速、高效且易于使用。

包含的WASM支持允许其在Web应用程序中使用,同时可以选择为前端和后端使用相同的代码库。

特性

  • 完全异步和响应式
  • WASM支持
  • 使用Tokio进行异步运行时
  • API足够简单,可用于各种应用程序
  • 包含一个低代码编辑器作为Logic Mesh如何使用的示例
  • 包含不断增长的内置块库
  • 可以通过自定义块扩展,这些块可以是Rust或WASM环境中的JavaScript

UI编辑器

有一个基于Logic Mesh构建的示例低代码编辑器,可以在此处找到。它作为Logic Mesh如何使用的示例,以及简单实验Logic Mesh引擎的简单方法。

NPM包

该引擎也作为NPM包提供,可以在此处找到。NPM包是WASM包的薄包装,可以在Node.js环境中使用。

示例

以下示例是用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;

依赖关系

~7–18MB
~224K SLoC