1use crate::ast::Expression;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct Rule {
7 pub name: String,
9 pub description: Option<String>,
11 pub salience: i32,
13 pub when_condition: Expression,
15 pub then_actions: Vec<Expression>,
17}
18
19impl Rule {
20 pub fn new(
22 name: String,
23 salience: i32,
24 when_condition: Expression,
25 then_actions: Vec<Expression>,
26 ) -> Self {
27 Self {
28 name,
29 description: None,
30 salience,
31 when_condition,
32 then_actions,
33 }
34 }
35
36 pub fn with_description(mut self, description: String) -> Self {
38 self.description = Some(description);
39 self
40 }
41}