pub struct Script { /* private fields */ }
Expand description

It is a wrapper of a plain text with graph-modifying instructions, for example:

ADD(0);
ADD($ν1); # adding new vertex
BIND(0, $ν1, foo);
PUT($ν1, d0-bf-D1-80-d0-B8-d0-b2-d0-b5-d1-82);

In the script you can use “variables”, similar to $ν1 used in the text above. They will be replaced by autogenerated numbers during the deployment of this script to a Sodg.

Implementations

Make a new one, parsing a string with instructions. Instructions must be separated by semicolon. There are just three of them possible: ADD, BIND, and PUT. The arguments must be separated by a comma. An argument may either be 1) a positive integer, 2) a variable started with $, 3) an attribute name, or 4) data in XX-XX-... hexadecimal format.

use sodg::Script;
use sodg::Sodg;
let mut s = Script::from_str(
  "ADD(0); ADD($ν1); BIND(0, $ν1, foo);"
);
let mut g = Sodg::empty();
let total = s.deploy_to(&mut g).unwrap();
assert_eq!(1, g.kid(0, "foo").unwrap());

Set a different root. By default, the root is set to zero. If the root is changed, each time zero-vertex is mentioned in instructions, if will be replaced by this number.

use sodg::Script;
use sodg::Sodg;
let mut s = Script::from_str(
  "ADD(1); BIND(0, 1, foo);"
);
s.set_root(42);
let mut g = Sodg::empty();
g.add(42).unwrap();
s.deploy_to(&mut g).unwrap();

Deploy the entire script to the SODG.

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.