30 releases

0.0.32 Mar 20, 2023
0.0.31 Mar 19, 2023
0.0.24 Feb 18, 2023
0.0.22 Jan 14, 2023
0.0.7 Oct 28, 2022

#177 in Memory management

Download history 3/week @ 2024-02-21 14/week @ 2024-02-28 86/week @ 2024-03-06 19/week @ 2024-03-13 410/week @ 2024-03-20 4/week @ 2024-03-27 5/week @ 2024-04-03 4/week @ 2024-04-24 1/week @ 2024-05-01

227 downloads per month

Custom license

115KB
2K SLoC

logo

EO principles respected here We recommend IntelliJ IDEA

cargo crates.io PDD status codecov Hits-of-Code Lines of code License docs.rs

This Rust library implements a Surging Object DiGraph (SODG) for reo virtual machine for EO programs. The graph is "surging" because it automatically behind the scene deletes vertices and edges from itself, which is also known as "garbage collection" mechanism. A vertex gets deleted right after the data it contains is read and no other vertices transitively point to it.

Here is how you can create a di-graph:

use sodg::Sodg;
use sodg::Hex;
let mut g = Sodg::empty();
g.add(0)?; // add a vertex no.0
g.add(1)?; // add a vertex no.1
g.bind(0, 1, "foo")?; // connect v0 to v1 with label "foo"
g.put(1, Hex::from_str_bytes("Hello, world!"))?; // attach data to v1

Then, you can find a vertex by the label of an edge departing from another vertex:

let id = g.kid(0, "foo")?;
assert_eq!(1, id);

Then, you can find all kids of a vertex:

let kids: Vec<(String, String, u32)> = g.kids(0);
assert_eq!("foo", kids[0].0);
assert_eq!("bar", kids[0].1);
assert_eq!(1, kids[0].2);

Then, you can read the data of a vertex:

let hex: Hex = g.data(1)?;
let num: i64 = hex.to_i64()?;
assert_eq!(42, num);

Then, you can print the graph:

println!("{:?}", g);

Using merge(), you can merge two graphs together, provided they are trees.

Using save() and load(), you can serialize and deserialize the graph.

Using to_xml() and to_dot(), you can print it to XML and DOT.

Using slice() and slice_some(), you can take a part/slice of the graph (mostly for debugging purposes).

Read the documentation.

How to Contribute

First, install Rust and then:

$ cargo test -vv

If everything goes well, fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run cargo test again. Also, run cargo fmt and cargo clippy.

Dependencies

~5–16MB
~180K SLoC