#graph #directed-graph #dsl #description #macro #relationships #describing

graphiti

graphiti provides a rust macro dsl and builder for creating and describing arbitrary sets of related data using a serializable description type

3 releases

0.1.2 Oct 16, 2023
0.1.1 Oct 15, 2023
0.1.0 Oct 15, 2023

#1585 in Data structures

Download history 8/week @ 2024-02-26 5/week @ 2024-03-11 56/week @ 2024-04-01

61 downloads per month

MIT license

10KB
166 lines

graphiti

github crates.io docs.rs

graphiti provides a rust macro dsl and builder for creating and describing arbitrary sets of related data, represented by a Description type.

A common use case is for modeling physical simulations, where you would want to leverage an entity component system but want the benefits of describing relationships between simulation members using directed graphs.

With graphiti, simulations can be described using a type-safe rust macro dsl that drives a builder pattern constructing a final Description type. With this Description, the data is organized and easily accessible for business logic that may want to use the stored data. This could be for a game (ECS + Scenegraphs), hardware simulations, etc.

Usage

Add this to your Cargo.toml:

graphiti = "0.1.2"

Example:

fn main() {
    let description = graphiti::describe! {
        nodes: {
            device: "device",
            safety: "safety",
            controller: "controller",
            power: "power",
            control: "control",
            io: "io"
        },
        edges: {
            "config_standard": {
                device: [safety, controller, power, control, io],
                safety: [controller, power]
            },
            "config_alternate": {
                device: [controller, control, io],
                controller: [power]
            }
        }
    };
    println!("{description:#?}");
}

Dependencies

~5.5MB
~91K SLoC