Crates.io | sot |
lib.rs | sot |
version | 0.0.2 |
source | src |
created_at | 2022-10-04 03:37:06.853766 |
updated_at | 2022-10-05 16:38:36.682491 |
description | Simple Object Tree |
homepage | https://github.com/objectionary/sot |
repository | https://github.com/objectionary/sot |
max_upload_size | |
id | 679588 |
size | 42,156 |
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.