Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Fluent builder for constructing token model schemas.

Implementations§

Source§

impl Builder

Source

pub fn new(name: &str) -> Self

Creates a new schema builder with the given name.

Source

pub fn version(self, v: &str) -> Self

Sets the schema version.

Source

pub fn data(self, id: &str, typ: &str) -> Self

Adds a data state.

Source

pub fn token(self, id: &str, initial: Option<i64>) -> Self

Adds a token-counting state.

Source

pub fn exported(self) -> Self

Marks the current state as exported.

Source

pub fn initial(self, value: i64) -> Self

Sets the initial value for the current state.

Source

pub fn action(self, id: &str) -> Self

Adds an action.

Source

pub fn guard(self, expr: &str) -> Self

Sets the guard expression for the current action.

Source

pub fn flow(self, source: &str, target: &str) -> Self

Adds an arc from source to target.

Source

pub fn arc(self, source: &str, target: &str) -> Self

Alias for flow.

Source

pub fn keys(self, keys: &[&str]) -> Self

Sets the map access keys for the current arc.

Source

pub fn value(self, v: &str) -> Self

Sets the value binding name for the current arc.

Source

pub fn constraint(self, id: &str, expr: &str) -> Self

Adds a constraint.

Source

pub fn ast(&self) -> &SchemaNode

Returns the underlying AST node.

Source

pub fn schema(self) -> Result<Schema, String>

Builds and returns the tokenmodel Schema.

Source

pub fn must_schema(self) -> Schema

Builds and returns the tokenmodel Schema. Panics on error.

Source

pub fn to_string(&self) -> String

Generates the S-expression DSL representation.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.