drifting-in-space / aper

Licence: MIT License
A Rust data structure library built on state machines.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to aper

Hal
🔴 A non-deterministic finite-state machine for Android & JVM that won't let you down
Stars: ✭ 63 (-37%)
Mutual labels:  state-machine, state
Xstate
State machines and statecharts for the modern web.
Stars: ✭ 18,300 (+18200%)
Mutual labels:  state-machine, state
Little State Machine
📠 React custom hook for persist state management
Stars: ✭ 654 (+554%)
Mutual labels:  state-machine, state
Machinery
State machine thin layer for structs (+ GUI for Phoenix apps)
Stars: ✭ 367 (+267%)
Mutual labels:  state-machine, state
SimpleStateMachineLibrary
📚 A simple library for realization state machines in C# code
Stars: ✭ 30 (-70%)
Mutual labels:  state-machine, state
React-Machinery
🔥 React Machinery provides a simple to use, component based approach to state machines in react.
Stars: ✭ 104 (+4%)
Mutual labels:  state-machine, state
Finity
A finite state machine library for Node.js and the browser with a friendly configuration DSL.
Stars: ✭ 88 (-12%)
Mutual labels:  state-machine, state
statemachine-go
🚦 Declarative Finite-State Machines in Go
Stars: ✭ 47 (-53%)
Mutual labels:  state-machine, state
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+21186%)
Mutual labels:  state-machine, state
StateBuilder
State machine code generator for C++ and Java.
Stars: ✭ 30 (-70%)
Mutual labels:  state-machine, state
tstate-machine
TypeScript implementation of State Manager(like StateMachine)
Stars: ✭ 20 (-80%)
Mutual labels:  state-machine, state
xstate-viz
Visualizer for XState machines
Stars: ✭ 274 (+174%)
Mutual labels:  state-machine, state
react-wisteria
Managing the State with the Golden Path
Stars: ✭ 18 (-82%)
Mutual labels:  state
StateMachine system for Godot
Flexible and lightweight StateMachine for Godot
Stars: ✭ 19 (-81%)
Mutual labels:  state
graph-crdt
Commutative graphs made for real-time, offline-tolerant replication
Stars: ✭ 47 (-53%)
Mutual labels:  state
closeable-map
Application state management made simple: a Clojure map that implements java.io.Closeable.
Stars: ✭ 42 (-58%)
Mutual labels:  state
react-gizmo
🦎 React Gizmo - UI Finite State Machine for React
Stars: ✭ 39 (-61%)
Mutual labels:  state-machine
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (-46%)
Mutual labels:  state-machine
spring-statemachine-learning
spring-statemachine 学习记录
Stars: ✭ 84 (-16%)
Mutual labels:  state-machine
xstate-cpp-generator
C++ State Machine generator for Xstate
Stars: ✭ 33 (-67%)
Mutual labels:  state-machine

Aper

GitHub Repo stars crates.io docs.rs wokflow state

Cartoonized face of an ape.

Aper is a data structure library in which every data structure is a state machine, and every mutation is a first-class value that can be serialized and sent over the network, or stored for later.

What is a state machine?

For the purposes of Aper, a state machine is simply a struct or enum that implements StateMachine and has the following properties:

  • It defines a StateMachine::Transition type, through which every possible change to the state can be described. It is usually useful, though not required, that this be an enum type.
  • It defines a StateMachine::Conflict type, which describes a conflict which may occur when a transition is applied that is not valid at the time it is applied. For simple types where a conflict is impossible, you can use NeverConflict for this.
  • All state updates are deterministic: if you clone a StateMachine and a Transition, the result of applying the cloned transition to the cloned state must be identical to applying the original transition to the original state.

Here's an example StateMachine implementing a counter:

use aper::{StateMachine, NeverConflict};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Clone, Debug, Default)]
struct Counter { value: i64 };

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
enum CounterTransition {
    Reset,
    Increment(i64),
    Decrement(i64),
}

impl StateMachine for Counter {
    type Transition = CounterTransition;
    type Conflict = NeverConflict;

    fn apply(&mut self, event: CounterTransition) -> Result<(), NeverConflict> {
        match event {
            CounterTransition::Reset => { self.value = 0 }
            CounterTransition::Increment(amount) => { self.value += amount }
            CounterTransition::Decrement(amount) => { self.value -= amount }
        }

        Ok(())
    }
}

Why not CRDT?

Conflict-free replicated data types are a really neat way of representing data that's shared between peers. In order to avoid the need for a central “source of truth”, CRDTs require that update operations (i.e. state transitions) be commutative. This allows them to represent a bunch of common data structures, but doesn't allow you to represent arbitrarily complex update logic. By relying on a central authority, a state-machine approach allows you to implement data structures with arbitrary update logic, such as atomic moves of a value between two data structures, or the rules of a board game.


Aper is rapidly evolving. Consider this a technology preview. See the list of issues outstanding for version 1.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].