veloren_rtsim/rule/
mod.rs

1pub mod cleanup;
2pub mod migrate;
3pub mod npc_ai;
4pub mod replenish_resources;
5pub mod report;
6pub mod simulate_npcs;
7pub mod sync_npcs;
8
9use super::RtState;
10use std::fmt;
11
12#[derive(Debug)]
13pub enum RuleError {
14    NoSuchRule(&'static str),
15}
16
17impl fmt::Display for RuleError {
18    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19        match self {
20            Self::NoSuchRule(r) => {
21                write!(f, "tried to fetch rule state '{}' but it does not exist", r)
22            },
23        }
24    }
25}
26
27pub trait Rule: Sized + Send + Sync + 'static {
28    fn start(rtstate: &mut RtState) -> Result<Self, RuleError>;
29}