Struct bevy_generative_grammars::tracery::TraceryGrammar
source · pub struct TraceryGrammar { /* private fields */ }
Expand description
This is a grammar that handles rules provided in a tracery syntax. See - https://github.com/galaxykate/tracery for more info on Tracery.
Implementations§
source§impl TraceryGrammar
impl TraceryGrammar
Trait Implementations§
source§impl Clone for TraceryGrammar
impl Clone for TraceryGrammar
source§fn clone(&self) -> TraceryGrammar
fn clone(&self) -> TraceryGrammar
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Component for TraceryGrammarwhere
Self: Send + Sync + 'static,
impl Component for TraceryGrammarwhere Self: Send + Sync + 'static,
source§impl Debug for TraceryGrammar
impl Debug for TraceryGrammar
source§impl<'de> Deserialize<'de> for TraceryGrammar
impl<'de> Deserialize<'de> for TraceryGrammar
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Generator<String, String, String, TraceryGrammar> for StringGenerator
impl Generator<String, String, String, TraceryGrammar> for StringGenerator
source§fn generate<R: GrammarRandomNumberGenerator>(
grammar: &TraceryGrammar,
rng: &mut R
) -> Option<String>
fn generate<R: GrammarRandomNumberGenerator>( grammar: &TraceryGrammar, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from the grammar’s default rulesource§fn generate_at<R: GrammarRandomNumberGenerator>(
key: &String,
grammar: &TraceryGrammar,
rng: &mut R
) -> Option<String>
fn generate_at<R: GrammarRandomNumberGenerator>( key: &String, grammar: &TraceryGrammar, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from a provided rule keysource§fn expand_from<R: GrammarRandomNumberGenerator>(
initial: &String,
grammar: &TraceryGrammar,
rng: &mut R
) -> String
fn expand_from<R: GrammarRandomNumberGenerator>( initial: &String, grammar: &TraceryGrammar, rng: &mut R ) -> String
This function generates a new value of
StreamType
, starting by processing an initial input of StreamType
source§impl Grammar<String, String, String> for TraceryGrammar
impl Grammar<String, String, String> for TraceryGrammar
source§fn rule_keys(&self) -> &Vec<String>
fn rule_keys(&self) -> &Vec<String>
Gets a Vec of all the possible rule keys - can be used to see if any match
source§fn default_starting_point(&self) -> &String
fn default_starting_point(&self) -> &String
Gets the default starting key - used if no other key is set
source§fn get_rule_options(&self, rule: &String) -> Option<&Vec<String>>
fn get_rule_options(&self, rule: &String) -> Option<&Vec<String>>
Gets all the possible expansions from a rule key
source§fn check_token_stream(
&self,
stream: &String
) -> (bool, Vec<Replacable<String, String>>)
fn check_token_stream( &self, stream: &String ) -> (bool, Vec<Replacable<String, String>>)
Parses a token stream and determines a) whether there are any tokens to replace and b) if so, which
The bool is true if there are no more tokens that need replacing
source§fn rule_to_default_result(&self, rule: &String) -> String
fn rule_to_default_result(&self, rule: &String) -> String
Converts a rule key to a default result, in case no matching rule is found in the grammar.
source§fn processing_direction(&self) -> GrammarProcessingDirection
fn processing_direction(&self) -> GrammarProcessingDirection
determines if the grammar should be processed breadth-first or depth-first
source§fn result_to_stream(&self, result: &[String]) -> String
fn result_to_stream(&self, result: &[String]) -> String
Converts a group of result types to a stream type
source§fn set_additional_rules(&mut self, rule: String, values: &[String])
fn set_additional_rules(&mut self, rule: String, values: &[String])
This is a function for setting a new rule. The expectation is that it overrides the original.
source§fn stream_to_result(&self, stream: &String) -> Vec<String>
fn stream_to_result(&self, stream: &String) -> Vec<String>
Converts a stream to a vec of result type
source§fn select_from_rule<R: GrammarRandomNumberGenerator>(
&self,
rule: &RuleKeyType,
rng: &mut R
) -> Option<&ResultType>
fn select_from_rule<R: GrammarRandomNumberGenerator>( &self, rule: &RuleKeyType, rng: &mut R ) -> Option<&ResultType>
Selects an element from a rule’s options. provides a default implementation in case no weighting is ncessessary.
The RNG function should accept the total number of options, and return a single id (a number less than the total). If it is larger, we will use the last element.
source§fn copy_and_replace_rules(&mut self, other: &Self)
fn copy_and_replace_rules(&mut self, other: &Self)
This is used to clone all the roles from another grammar into this one. This is used by stateful generators to update their state.
source§fn max_depth(&self) -> usize
fn max_depth(&self) -> usize
Provides the maximum depth (number of iterations) allowed for the generator. It will always quit early if it stabilizes,
but otherwise it will conclude when it reaches the provided depth.
source§fn process_stream<R: GrammarRandomNumberGenerator>(
&self,
stream: &StreamType,
rng: &mut R,
temporary_grammar: &mut Self
) -> StreamType
fn process_stream<R: GrammarRandomNumberGenerator>( &self, stream: &StreamType, rng: &mut R, temporary_grammar: &mut Self ) -> StreamType
Takes a token stream, checks it for replacements, and then applies them by using select from rule.
It returns a bool indicating whether it had to make any replacements this round, and a vec of the results.
source§fn breadth_first_processing<R: GrammarRandomNumberGenerator>(
&self,
stream: &StreamType,
temporary_grammar: &mut Self,
rng: &mut R
) -> StreamType
fn breadth_first_processing<R: GrammarRandomNumberGenerator>( &self, stream: &StreamType, temporary_grammar: &mut Self, rng: &mut R ) -> StreamType
Processes a stream breadth first, regardless of the settings of the grammar
source§fn depth_first_processing<R: GrammarRandomNumberGenerator>(
&self,
stream: &StreamType,
temporary_grammar: &mut Self,
rng: &mut R
) -> StreamType
fn depth_first_processing<R: GrammarRandomNumberGenerator>( &self, stream: &StreamType, temporary_grammar: &mut Self, rng: &mut R ) -> StreamType
Processes a stream depth first, regardless of the settings of the grammar
source§impl Serialize for TraceryGrammar
impl Serialize for TraceryGrammar
source§impl StatefulGenerator<String, String, String, TraceryGrammar> for StatefulStringGenerator
impl StatefulGenerator<String, String, String, TraceryGrammar> for StatefulStringGenerator
source§fn generate<R: GrammarRandomNumberGenerator>(
&mut self,
rng: &mut R
) -> Option<String>
fn generate<R: GrammarRandomNumberGenerator>( &mut self, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from the grammar’s default rulesource§fn generate_at<R: GrammarRandomNumberGenerator>(
&mut self,
key: &String,
rng: &mut R
) -> Option<String>
fn generate_at<R: GrammarRandomNumberGenerator>( &mut self, key: &String, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from a provided rule keysource§fn expand_from<R: GrammarRandomNumberGenerator>(
&mut self,
initial: &String,
rng: &mut R
) -> String
fn expand_from<R: GrammarRandomNumberGenerator>( &mut self, initial: &String, rng: &mut R ) -> String
This function generates a new value of
StreamType
, starting by processing an initial input of StreamType
source§fn set_grammar(&mut self, grammar: &TraceryGrammar)
fn set_grammar(&mut self, grammar: &TraceryGrammar)
This sets the used grammar
source§fn get_grammar(&self) -> &TraceryGrammar
fn get_grammar(&self) -> &TraceryGrammar
This gets an immutable reference to the grammar
source§fn get_grammar_mut(&mut self) -> &mut TraceryGrammar
fn get_grammar_mut(&mut self) -> &mut TraceryGrammar
This gets a mutable reference to the grammar
source§impl TypePath for TraceryGrammar
impl TypePath for TraceryGrammar
source§fn type_path() -> &'static str
fn type_path() -> &'static str
Returns the fully qualified path of the underlying type. Read more
source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Returns a short, pretty-print enabled path to the type. Read more
source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
source§impl VisitAssetDependencies for TraceryGrammar
impl VisitAssetDependencies for TraceryGrammar
fn visit_dependencies(&self, _visit: &mut impl FnMut(UntypedAssetId))
impl Asset for TraceryGrammar
impl Resource for TraceryGrammarwhere Self: Send + Sync + 'static,
Auto Trait Implementations§
impl RefUnwindSafe for TraceryGrammar
impl Send for TraceryGrammar
impl Sync for TraceryGrammar
impl Unpin for TraceryGrammar
impl UnwindSafe for TraceryGrammar
Blanket Implementations§
§impl<A> AssetContainer for Awhere
A: Asset,
impl<A> AssetContainer for Awhere A: Asset,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere C: Component,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )
§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere T: TypePath,
§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
See [
TypePath::type_path
].§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
See [
TypePath::short_type_path
].§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
See [
TypePath::type_ident
].§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
See [
TypePath::crate_name
].§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
See [
TypePath::module_path
].