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§
sourcefn set_grammar(&mut self, grammar: &GrammarType)
fn set_grammar(&mut self, grammar: &GrammarType)
This sets the used grammar
sourcefn get_grammar(&self) -> &GrammarType
fn get_grammar(&self) -> &GrammarType
This gets an immutable reference to the grammar
sourcefn get_grammar_mut(&mut self) -> &mut GrammarType
fn get_grammar_mut(&mut self) -> &mut GrammarType
This gets a mutable reference to the grammar
sourcefn generate<R: GrammarRandomNumberGenerator>(
&mut self,
rng: &mut R
) -> Option<StreamType>
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
sourcefn generate_at<R: GrammarRandomNumberGenerator>(
&mut self,
key: &RuleKeyType,
rng: &mut R
) -> Option<StreamType>
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
sourcefn expand_from<R: GrammarRandomNumberGenerator>(
&mut self,
initial: &StreamType,
rng: &mut R
) -> StreamType
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