[][src]Struct tracery::Grammar

pub struct Grammar { /* fields omitted */ }

Represents a single grammar

This is the main data type used with this library.

Implementations

impl Grammar[src]

pub fn new() -> Grammar[src]

Create a new default Grammar

pub fn get_modifier(&self, modifier: &str) -> Option<&dyn Fn(&str) -> String>[src]

Gets a single modifier with the given name, if it exists

pub fn get_rule(&self, key: &str) -> Option<&Vec<Rule>>[src]

Gets a rule with the given key, if it exists

pub fn from_json<S: AsRef<str>>(s: S) -> Result<Grammar>[src]

Creates a new grammar from a JSON grammar string

pub fn default_rule<S: Into<String>>(self, s: S) -> Grammar[src]

Sets a default rule for the Grammar

Returns

The modified Grammar

pub fn add_rules<S: Into<String>>(
    &mut self,
    name: S,
    rules: Vec<Rule>
) -> Result<()>
[src]

Adds a rule with the given key and list of rules to the Grammar

Returns

Ok(()) on success Error otherwise

Trait Implementations

impl Default for Grammar[src]

impl Flatten for Grammar[src]

Auto Trait Implementations

impl !RefUnwindSafe for Grammar

impl !Send for Grammar

impl !Sync for Grammar

impl Unpin for Grammar

impl !UnwindSafe for Grammar

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,