2 releases

0.0.2 Oct 5, 2022
0.0.1 Oct 4, 2022

#1784 in Data structures

Custom license

39KB
746 lines

logo

EO principles respected here We recommend IntelliJ IDEA

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

This Rust library helps you build an object tree for reo compiler of EO programs.

Create a tree:

use sot::Sot;
let mut sot = Sot::empty();
sot.add(0)?; // add a vertex no.0
sot.add(1)?; // add a vertex no.1
sot.bind(0, 1, "foo")?; // connect v0 to v1 with label "foo"
sot.put(1, "Hello, world!".as_bytes().to_vec())?; // attach data to v1

You can find a vertex by the label of an edge departing from another vertex:

let id = sot.kid(0, "foo")?; // returns 1

You can find all kids of a vertex:

let kids: Vec<(String, u32)> = sot.kids(0);

You can read the data of a vertex:

let bytes: Vec<u8> = sot.data(1)?; // empty if no data written before

Then, you can print the tree:

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

Also, you can serialize and deserialize the tree.

Dependencies

~4–5.5MB
~107K SLoC