pub struct DialectConfig {
pub grammar: Grammar,
/* private fields */
}Expand description
Bundles a grammar with its dialect-specified wordlist references.
Each dialect in grammar.yaml may declare payload_wordlist and cover_wordlist
to bind a specific payload/cover pair. If omitted, both default to "default".
The CLI --wordlist flag overrides payload_wordlist (and its implied cover).
§Examples
use glossia::grammar::DialectConfig;
// Load the Latin spells dialect — automatically resolves payload_hp.yaml + cover.yaml
let config = DialectConfig::from_language_dialect("latin", "spells").unwrap();
assert_eq!(config.payload_wordlist(), "hp");
assert_eq!(config.cover_wordlist(), "default");Fields§
§grammar: GrammarThe grammar (CFG rules + type system) for this dialect.
Implementations§
Source§impl DialectConfig
impl DialectConfig
Sourcepub fn from_language_dialect(
language: &str,
dialect: &str,
) -> Result<Self, Box<dyn Error>>
pub fn from_language_dialect( language: &str, dialect: &str, ) -> Result<Self, Box<dyn Error>>
Load a dialect configuration from grammar.yaml.
Reads the dialects.<dialect>.payload_wordlist and dialects.<dialect>.cover_wordlist
fields. Falls back to "default" when fields are absent (backward compatible).
If the dialect defines a scale: section (intervals + root), the payload wordlist
is derived at runtime from the base chromatic payload filtered by the scale pattern.
The derived words are injected into the in-memory cache so that subsequent
load_payload_words_for_wordlist() calls find them transparently.
Sourcepub fn payload_wordlist(&self) -> &str
pub fn payload_wordlist(&self) -> &str
Payload wordlist profile name (e.g., “default”, “hp”, “bip39”).
Sourcepub fn scale(&self) -> Option<&ScaleDefinition>
pub fn scale(&self) -> Option<&ScaleDefinition>
Scale definition, if this dialect derives its payload from interval patterns.
Sourcepub fn cover_wordlist(&self) -> &str
pub fn cover_wordlist(&self) -> &str
Cover wordlist profile name (e.g., “default”).
Sourcepub fn payload_language(&self) -> &str
pub fn payload_language(&self) -> &str
The language used to resolve payload wordlist files.
Returns payload_language if set, otherwise falls back to self.language.
Sourcepub fn n_refinement_tag(&self) -> Option<String>
pub fn n_refinement_tag(&self) -> Option<String>
Get the refinement tag for N (payload note) slots, if any.
Returns the auto-derived or explicit type_refinements tag for the N POS.
This is used to populate Lexicon::refined_payload for runtime validation.
Sourcepub fn with_payload_wordlist(self, wordlist: &str) -> Self
pub fn with_payload_wordlist(self, wordlist: &str) -> Self
Override the payload wordlist (e.g., from CLI --wordlist flag).
This also updates the cover wordlist to the corresponding named variant
if one exists, otherwise leaves cover unchanged.
Sourcepub fn with_cover_wordlist(self, wordlist: &str) -> Self
pub fn with_cover_wordlist(self, wordlist: &str) -> Self
Override the cover wordlist explicitly.
Sourcepub fn wordlist_filenames(&self) -> (String, String)
pub fn wordlist_filenames(&self) -> (String, String)
Resolve payload and cover filenames for this dialect.
Returns (payload_filename, cover_filename) — e.g., ("payload_hp.yaml", "cover.yaml").
Uses payload_language (if set) to resolve payload files from a different language.
Sourcepub fn available_dialects(language: &str) -> Vec<String>
pub fn available_dialects(language: &str) -> Vec<String>
List all dialect names defined in a language’s grammar.yaml.
Returns the base dialect “body” plus all names under the dialects: key.
Trait Implementations§
Source§impl Clone for DialectConfig
impl Clone for DialectConfig
Source§fn clone(&self) -> DialectConfig
fn clone(&self) -> DialectConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DialectConfig
impl RefUnwindSafe for DialectConfig
impl Send for DialectConfig
impl Sync for DialectConfig
impl Unpin for DialectConfig
impl UnsafeUnpin for DialectConfig
impl UnwindSafe for DialectConfig
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more