pub trait StatefulGenerator<RuleKeyType: Clone + PartialEq + Debug, GrammarResultType: Clone + PartialEq + Debug, StreamType: Clone + PartialEq + Debug, GrammarType: Grammar<RuleKeyType, GrammarResultType, StreamType>> {
    // Required methods
    fn set_grammar(&mut self, grammar: &GrammarType);
    fn get_grammar(&self) -> &GrammarType;
    fn get_grammar_mut(&mut self) -> &mut GrammarType;
    fn generate<R: GrammarRandomNumberGenerator>(
        &mut self,
        rng: &mut R
    ) -> Option<StreamType>;
    fn generate_at<R: GrammarRandomNumberGenerator>(
        &mut self,
        key: &RuleKeyType,
        rng: &mut R
    ) -> Option<StreamType>;
    fn expand_from<R: GrammarRandomNumberGenerator>(
        &mut self,
        initial: &StreamType,
        rng: &mut R
    ) -> StreamType;
}
Expand description

This trait represents a stateful generator. Here the generator owns the grammar, allowing it to make adjustments as needed.

Required Methods§

source

fn set_grammar(&mut self, grammar: &GrammarType)

This sets the used grammar

source

fn get_grammar(&self) -> &GrammarType

This gets an immutable reference to the grammar

source

fn get_grammar_mut(&mut self) -> &mut GrammarType

This gets a mutable reference to the grammar

source

fn generate<R: GrammarRandomNumberGenerator>( &mut self, rng: &mut R ) -> Option<StreamType>

This function generates a new value of StreamType, starting from the grammar’s default rule

source

fn generate_at<R: GrammarRandomNumberGenerator>( &mut self, key: &RuleKeyType, rng: &mut R ) -> Option<StreamType>

This function generates a new value of StreamType, starting from a provided rule key

source

fn expand_from<R: GrammarRandomNumberGenerator>( &mut self, initial: &StreamType, rng: &mut R ) -> StreamType

This function generates a new value of StreamType, starting by processing an initial input of StreamType

Implementors§