GitXplorerGitXplorer
G

rearch-rs

public
84 stars
4 forks
1 issues

Commits

List of commits on branch main.
Verified
3eb0ae4e68c545b18a9965da20bd8cdd167a049f

ci: update the WASI test runner

GGregoryConrad committed 9 days ago
Unverified
5e8c7765e863c9ec4537cba5511f231e17204300

ci: silence warning from latest nightly

GGregoryConrad committed 9 days ago
Unverified
78c572b2e6b9381f92e0a48e772d38803d3a1f5c

chore(deps): update axum requirement from 0.7.5 to 0.8.1

ddependabot[bot] committed 13 days ago
Verified
6f63bb00eed80e0632e1314ee29b5a4737e99b15

ci: simplify dependabot.yaml

GGregoryConrad committed a month ago
Unverified
1bbdf4740eaa0f7563ff9152611a672579061910

style: updates for latest clippy lints

GGregoryConrad committed 2 months ago
Unverified
d3c86606efd582589b9250c504842e25ebdc8cf5

style: accommodate latest clippy lints

GGregoryConrad committed 3 months ago

README

The README file for this repository.

CI Status Github Stars MIT License

Banner

ReArch = re-imagined approach to application design and architecture

We must state definitions and provide for priorities and descriptions of data. We must state relationships, not procedures.

-- Grace Murray Hopper, Management and the Computer of the Future (1962)


Features

Specifically, ReArch is a novel solution to:

  • ⚡️ State Management
  • 🧮 Incremental Computation
  • 🧱 Component-Based Software Engineering

And with those, come:

In a Nutshell

Define your "capsules" (en-capsulated pieces of state) at the top level:

// Capsules are simply functions that consume a CapsuleHandle.
// The CapsuleHandle lets you get the state of other capsules,
// in addition to using a large variety of side effects.

// This capsule provides the count and a way to increment that count.
fn count_manager(CapsuleHandle { register, .. }: CapsuleHandle) -> (u8, impl CData + Fn()) {
    let (count, set_count) = register(effects::state::<Cloned<_>>(0));
    let increment_count = move || set_count(count + 1);
    (count, increment_count)
}

// This capsule provides the count, plus one.
fn count_plus_one_capsule(CapsuleHandle { mut get, .. }: CapsuleHandle) -> u8 {
    let (count, _increment_count) = get(count_manager);
    count + 1
}

let container = Container::new();

let ((count, increment_count), count_plus_one) =
    container.read((count_manager, count_plus_one_capsule));
assert_eq!(count, 0);
assert_eq!(count_plus_one, 1);

increment_count();

let ((count, _), count_plus_one) =
    container.read((count_manager, count_plus_one_capsule));
assert_eq!(count, 1);
assert_eq!(count_plus_one, 2);

[!NOTE] The syntax used in the example above requires nightly for unboxed_closures and fn_traits, which is feature-gated under the experimental-api feature. Once unboxed_closures and fn_traits stabilize, this nightly syntax will be the preferred syntax, and this will no longer be feature-gated. (Without nightly, you must instead call the slightly more verbose get.as_ref(some_capsule).clone() and register.register(effect()).)

Getting Started

Simply run: cargo add rearch rearch-effects

Then, create one container for your application:

use rearch::*;
use rearch_effects as effects;

fn main() {
  let container = Container::new();
  // Use the container.
}

And take a look at the examples to get an idea on how to make some of your own capsules!

Documentation

Also, there is some WIP documentation that will help you learn the core concepts behind ReArch!

Minimum Supported Rust Version (MSRV)

The MSRV is the current stable Rust version for all crates in this repo. As such, any new release may require an updated Rust installation.

Help Wanted!

As much as I have done with ReArch, it always seems like there is more to do. One person can only do so much!

If you would like to contribute, here are some areas where I would really appreciate help!

  • Documentation (especially inline!)
    • If you could add code samples/improve clarity, that would be greatly appreciated.
  • New side effects!
    • I've made many as I've needed them, but it'd be great to have more.
    • If you find yourself using a custom side effect over and over, consider making a PR! Chances are other developers can use it too.

Sponsors

You can become a sponsor of my work here!