pub struct RedirectionRule {
pub glob_pattern: String,
pub target: Option<RuleTarget>,
pub mode: RedirectionMode,
pub patches: Vec<MemoryPatch>,
pub enable_if: Option<String>,
}Expand description
A single glob-based redirection rule.
Fields§
§glob_pattern: StringGlob pattern matched against the file path the game requests,
relative to the game’s root directory (e.g. data/levels/*.dat).
target: Option<RuleTarget>The replacement asset for files matching the glob, relative to the
game’s root directory unless absolute, either a plain local path
(RuleTarget::Path, the classic string form) or a remote-backed
managed file (RuleTarget::Managed, struct form; the local path
plus where fresh content comes from and how often to refresh it).
Omittable, None means no replacement is configured yet (e.g. a
rule scaffolded ahead of the asset being dropped in), and is
treated exactly like “the replacement doesn’t exist”: GracefulFallback
mode passes through to the original, HardError mode blocks the
operation. When present, its meaning depends on the glob’s shape,
see RedirectionRule::is_literal_glob:
- Wildcard glob (contains
*,?, or[, e.g.data/levels/*.datormods_source/**): the target’s local path is a directory. The portion of the matched path below the glob’s fixed prefix is joined onto it, preserving relative structure. - Literal glob (no wildcard at all, e.g.
Saved_Data/high_times.txt): the rule can only ever match that one exact path, so the target’s local path is the replacement file itself, used as-is, nothing is joined onto it. A managed target additionally requires a literal glob (one remote URL can only name one file), enforced byModConfig::validate.
mode: RedirectionMode§patches: Vec<MemoryPatch>Content modifications applied to the replacement file’s bytes before they’re written to the temp redirection target. Empty by default: most rules only redirect, they don’t also patch bytes.
enable_if: Option<String>References a crate::mod_config::ModParameter::id within the same mod. When
present, this rule only participates in ModConfig::resolved_rules
if that parameter’s current value is “on”, a true boolean, or a
non-empty dropdown selection (see ModConfig for the full
picture). None means the rule is unconditionally active.
Implementations§
Source§impl RedirectionRule
impl RedirectionRule
Sourcepub fn is_literal_glob(&self) -> bool
pub fn is_literal_glob(&self) -> bool
True if glob_pattern contains no wildcard characters (*, ?,
[), meaning it can only ever match exactly one path. Such rules
treat target as the replacement file directly rather than a
directory to join a matched suffix into, see the field docs on
RedirectionRule::target.
Trait Implementations§
Source§impl Clone for RedirectionRule
impl Clone for RedirectionRule
Source§fn clone(&self) -> RedirectionRule
fn clone(&self) -> RedirectionRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedirectionRule
impl Debug for RedirectionRule
Source§impl<'de> Deserialize<'de> for RedirectionRule
impl<'de> Deserialize<'de> for RedirectionRule
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>,
Source§impl PartialEq for RedirectionRule
impl PartialEq for RedirectionRule
Source§fn eq(&self, other: &RedirectionRule) -> bool
fn eq(&self, other: &RedirectionRule) -> bool
self and other values to be equal, and is used by ==.