Trait mz_sql::query_model::rewrite::Rule
source · pub(crate) trait Rule {
type Match;
fn name(&self) -> &'static str;
fn strategy(&self) -> ApplyStrategy;
fn required_attributes(&self) -> HashSet<Box<dyn Attribute>>;
fn check(&self, model: &Model, box_id: BoxId) -> Option<Self::Match>;
fn rewrite(&self, model: &mut Model, mat: Self::Match);
}Expand description
Trait that all rewrite rules must implement.
Required Associated Types§
Required Methods§
sourcefn strategy(&self) -> ApplyStrategy
fn strategy(&self) -> ApplyStrategy
The ApplyStrategy for the rule.
sourcefn required_attributes(&self) -> HashSet<Box<dyn Attribute>>
fn required_attributes(&self) -> HashSet<Box<dyn Attribute>>
Derived attributes required by this Rule.
sourcefn check(&self, model: &Model, box_id: BoxId) -> Option<Self::Match>
fn check(&self, model: &Model, box_id: BoxId) -> Option<Self::Match>
Determines how to rewrite the box.
Returns None if the box does not need to be rewritten.
sourcefn rewrite(&self, model: &mut Model, mat: Self::Match)
fn rewrite(&self, model: &mut Model, mat: Self::Match)
Rewrites the Model based on the parameters of Self::Match
determined by a previous Rule::check call.