Struct sodg::Script

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

A wrapper of a plain text with graph-modifying instructions.

For example, you can pass the following instructions to it:

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§

source§

impl Script

source

pub fn from_str(s: &str) -> Script

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 (possibly prepended by ν), 2) a variable started with $, 3) an attribute name, or 4) data in XX-XX-... hexadecimal format.

For example:

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().0);
source

pub fn from_string(s: String) -> Script

Make a new one, parsing a String with instructions.

source

pub fn deploy_to(&mut self, g: &mut Sodg) -> Result<usize>

Deploy the entire script to the Sodg.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.