2 unstable releases
Uses new Rust 2024
| new 0.7.0 | Feb 22, 2026 |
|---|---|
| 0.2.0 | Feb 22, 2026 |
#1327 in Procedural macros
16KB
343 lines
Ranvier — Typed Decision Engine for Rust
Execution you can read. Structure you can trust.
Ranvier is not a web framework. It is a Typed Decision Engine that keeps execution explicit, structure inspectable, and boundaries clear. Your Rust logic becomes a circuit you can reason about, diff, and validate.
What Ranvier is
- Axon: explicit execution chain built from typed transitions.
- Schematic: static structural artifact extracted from Axon. It never executes runtime logic.
- Outcome: control-flow as data (
Next,Branch,Jump,Emit,Fault). - Ingress/Egress: protocol adapters at the boundary (HTTP lives here, not in core).
- Bus: typed resource container that stays explicit (no hidden injection).
Quickstart
cargo add ranvier
cargo add tokio --features full
cargo add anyhow
cargo add async-trait
use async_trait::async_trait;
use ranvier::prelude::*;
#[derive(Clone)]
struct Hello;
#[async_trait]
impl Transition<(), String> for Hello {
type Error = anyhow::Error;
type Resources = ();
async fn run(
&self,
_state: (),
_resources: &Self::Resources,
_bus: &mut Bus,
) -> Outcome<String, Self::Error> {
Outcome::Next("Hello, Ranvier!".to_string())
}
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let hello = Axon::<(), (), anyhow::Error>::new("Hello")
.then(Hello);
Ranvier::http()
.bind("127.0.0.1:3000")
.route("/", hello)
.run(())
.await
.map_err(|e| anyhow::anyhow!("{}", e))?;
Ok(())
}
Ranvier::http() is an Ingress Builder, not a web server.
Canonical Examples
Run from this workspace:
cargo run -p hello-worldcargo run -p typed-state-treecargo run -p basic-schematic
See examples/README.md for tiers and additional workflows.
Workspace Structure
core/— protocol-agnostic contracts (Transition,Outcome,Bus,Schematic)runtime/— Axon execution enginehttp/— Ingress/Egress adapter boundarystd/— standard transitions and utilitiesmacros/— macro helpersextensions/— optional ecosystem modulesexamples/— runnable reference apps
Boundary Rules (Non-Negotiable)
- Core stays protocol-agnostic.
- Schematic is structural and non-executable.
- Flat API convenience must not hide control flow.
- No hidden middleware-style magic.
Links
Dependencies
~125–510KB
~12K SLoC