Write a Rule Plug-in
Rule plug-ins let you extend validation and scoring without forking the engine.
- Define a validator. Implement
RulePluginin Rust and register it under a ruleset ID. - Expose knobs. Serialize parameters (JSON or TOML) so configs can toggle the behavior.
- Wire into bindings. Export the new hook through FFI so Python/WASM/Unity/Godot can opt-in.
- Test it. Build fixture moves and cover failure cases in both unit tests and end-to-end demos.
no_short_words.rs
use engine::rules::{PluginContext, RuleFailure, RulePlugin};
#[derive(Default)]
pub struct NoShortWords;
impl RulePlugin for NoShortWords {
fn validate(&self, ctx: &PluginContext) -> Result<(), RuleFailure> {
if ctx.main_word.len() < 4 {
return Err(RuleFailure::reject("Words must be at least four letters"));
}
Ok(())
}
}