pub enum RuleSource {
Baked {
text: &'static str,
},
Disk {
path: PathBuf,
},
}Expand description
A source of rule text yielding a runtime Ruleset, in one of two modes
(doc 11 §4.2). Both modes call the same Ruleset::from_ron, so a baked
build and a disk build of the same rules.ron produce byte-identical
rulesets — the dual-mode guarantee.
Variants§
Baked
Baked (RELEASE): the canonical rules.ron text compiled into the
binary via the caller’s include_str!. Zero file IO. The default build.
Disk
Disk (DEV): rules.ron read from a file path. With the hot-reload
feature a Watcher observes the file and
poll_changed signals edits so the registry
is rebuilt between turns.
Implementations§
Source§impl RuleSource
impl RuleSource
Sourcepub fn baked(text: &'static str) -> Self
pub fn baked(text: &'static str) -> Self
A baked source over include_str!’d text (RELEASE; the default build).
The text is compiled into the binary; loading never touches the filesystem.
Sourcepub fn from_path(path: impl Into<PathBuf>) -> Self
pub fn from_path(path: impl Into<PathBuf>) -> Self
A disk source over a rules.ron path (DEV). Without the hot-reload
feature this still reads the file at load time (it
just never watches it); with the feature it also starts a watcher so
poll_changed can signal edits.
Sourcepub fn load(&self) -> Result<Ruleset, LoadError>
pub fn load(&self) -> Result<Ruleset, LoadError>
Read the current rule text + parse it into a Ruleset. The decisive
dual-mode invariant: baked text and disk text run through the same
Ruleset::from_ron, so identical bytes ⇒ identical ruleset.
Sourcepub fn poll_changed(&mut self) -> bool
pub fn poll_changed(&mut self) -> bool
Poll whether the on-disk rules.ron has changed since the last poll
(DEV / hot-reload). A true return is the game’s cue to re-load and
rebuild the compiled registry between turns (safe mid-battle —
doc 11 §4.2). A baked source never changes ⇒ always false; a disk
source without the hot-reload feature also returns false (no watcher).
Sourcepub fn is_hot_reloadable(&self) -> bool
pub fn is_hot_reloadable(&self) -> bool
Whether this source can hot-reload (a disk source with a live watcher).
false for a baked source or a feature-off build. Useful for diagnostics.