optd_core/rules.rs
1// Copyright (c) 2023-2024 CMU Database Group
2//
3// Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at
4// https://opensource.org/licenses/MIT.
5
6mod ir;
7
8pub use ir::RuleMatcher;
9
10use crate::nodes::{ArcPlanNode, NodeType, PlanNodeOrGroup};
11use crate::optimizer::Optimizer;
12
13// TODO: docs, possible renames.
14// TODO: Why do we have all of these match types? Seems like possible overkill.
15pub trait Rule<T: NodeType, O: Optimizer<T>>: 'static + Send + Sync {
16 fn matcher(&self) -> &RuleMatcher<T>;
17 fn apply(&self, optimizer: &O, binding: ArcPlanNode<T>) -> Vec<PlanNodeOrGroup<T>>;
18 fn name(&self) -> &'static str;
19 fn is_impl_rule(&self) -> bool {
20 false
21 }
22}