Struct sodg::Sodg

source · []
pub struct Sodg { /* private fields */ }
Expand description

This struct represents a Simple Object DiGraph (SODG). You add vertices to it, bind them one to one with edges

use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(0).unwrap();
sodg.add(1).unwrap();
sodg.bind(0, 1, "a").unwrap();
sodg.add(2).unwrap();
sodg.bind(1, 2, "b").unwrap();
assert_eq!(2, sodg.find(0, "a.b").unwrap());

Implementations

Finds an object by the provided locator and prints its tree of sub-objects and edges. Mostly used for testing.

Merge this new graph into itself.

Makes an empty Sodg, with no vertices and no edges.

Get max ID of a vertex.

Add a new vertex v1 to the Sodg:

use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(0).unwrap();
sodg.add(42).unwrap();
sodg.bind(0, 42, "hello").unwrap();

Makes an edge e1 from vertex v1 to vertex v2 and puts a label on it. If the label is not equal to "ρ", makes two backward edges from v2 to v1 and label them as "ρ" an "𝜎".

use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(0).unwrap();
sodg.add(42).unwrap();
sodg.bind(0, 42, "forward").unwrap();
sodg.bind(42, 0, "backward").unwrap();

Set vertex data.

use sodg::hex::Hex;
use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(42).unwrap();
sodg.put(42, Hex::from_str("hello, world!")).unwrap();

Read vertex data.

use sodg::hex::Hex;
use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(42).unwrap();
let data = Hex::from_str("hello, world!");
sodg.put(42, data.clone()).unwrap();
assert_eq!(data, sodg.data(42).unwrap());

Find all kids of a vertex.

Find a kid of a vertex, by its edge name.

use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(0).unwrap();
sodg.add(42).unwrap();
sodg.bind(0, 42, "k").unwrap();
assert_eq!(42, sodg.kid(0, "k").unwrap());
assert!(sodg.kid(0, "another").is_none());

Find a vertex in the Sodg by its locator.

use sodg::Sodg;
let mut sodg = Sodg::empty();
sodg.add(0).unwrap();
sodg.add(1).unwrap();
sodg.bind(0, 1, "a").unwrap();
sodg.add(2).unwrap();
sodg.bind(1, 2, "b").unwrap();
assert_eq!(2, sodg.find(0, "a.b").unwrap());

Save the entire Sodg into a binary file. The entire Sodg can be restored from the file. Returns the size of the file just saved.

Load the entire Sodg from a binary file previously created by save().

Take a slice of the Sodg, keeping only the vertex specified by the locator.

Make XML graph.

Attach a new alert to this SODG.

Disable all alerts.

Enable all alerts.

Trait Implementations

Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.