pub struct EngineBuilder<T, M, R, C>{ /* private fields */ }Expand description
A builder type for constructing and configuring Engine instances.
Implementations§
Source§impl<T, M, R> EngineBuilder<T, M, R, NoCache>
impl<T, M, R> EngineBuilder<T, M, R, NoCache>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder instance with the default select_first selector.
Source§impl<T, M, R, C> EngineBuilder<T, M, R, C>
impl<T, M, R, C> EngineBuilder<T, M, R, C>
Sourcepub fn build(self) -> Engine<T, M, R, C>
pub fn build(self) -> Engine<T, M, R, C>
Consumes the builder and returns the constructed Engine instance.
Sourcepub fn add_rule_group(self, rules: Vec<R>) -> Self
pub fn add_rule_group(self, rules: Vec<R>) -> Self
Adds a collection of rules with the same priority.
These rules will have a lower priority than previously added groups.
Sourcepub fn add_rule(self, rule: R) -> Self
pub fn add_rule(self, rule: R) -> Self
Adds a single rule in a group by itself.
This is a special case of add_rule_group.
Sourcepub fn append_rule_groups(self, groups: Vec<Vec<R>>) -> Self
pub fn append_rule_groups(self, groups: Vec<Vec<R>>) -> Self
Adds a collection of rule groups to the existing one.
Rule groups maintain the same order and will be lower priority than existing groups.
Sourcepub fn add_before_up(self, handler: fn(&T, &mut M)) -> Self
pub fn add_before_up(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called before moving $dir in the tree.
Sourcepub fn add_after_up(self, handler: fn(&T, &mut M)) -> Self
pub fn add_after_up(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called after moving $dir one node in the tree.
Sourcepub fn add_before_down(self, handler: fn(&T, &mut M)) -> Self
pub fn add_before_down(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called before moving $dir in the tree.
Sourcepub fn add_after_down(self, handler: fn(&T, &mut M)) -> Self
pub fn add_after_down(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called after moving $dir one node in the tree.
Sourcepub fn add_before_right(self, handler: fn(&T, &mut M)) -> Self
pub fn add_before_right(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called before moving $dir in the tree.
Sourcepub fn add_after_right(self, handler: fn(&T, &mut M)) -> Self
pub fn add_after_right(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called after moving $dir one node in the tree.
Sourcepub fn add_before_rule(self, handler: fn(&T, &mut M, &R)) -> Self
pub fn add_before_rule(self, handler: fn(&T, &mut M, &R)) -> Self
Register an event handler to be called before attempting a rule
Sourcepub fn add_after_rule(self, handler: fn(&T, &mut M, &R, bool)) -> Self
pub fn add_after_rule(self, handler: fn(&T, &mut M, &R, bool)) -> Self
Register an event handler to be called after attempting a rule The boolean signifies whether the rule is applicable
Sourcepub fn add_after_apply(self, handler: fn(&T, &mut M, &R)) -> Self
pub fn add_after_apply(self, handler: fn(&T, &mut M, &R)) -> Self
Register an event handler to be called after applying a rule
Sourcepub fn add_on_cache_hit(self, handler: fn(&T, &mut M)) -> Self
pub fn add_on_cache_hit(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called on a cache hit
Sourcepub fn add_on_cache_miss(self, handler: fn(&T, &mut M)) -> Self
pub fn add_on_cache_miss(self, handler: fn(&T, &mut M)) -> Self
Register an event handler to be called on a cache miss
Sourcepub fn set_selector(self, selector: SelectorFn<T, M, R>) -> Self
pub fn set_selector(self, selector: SelectorFn<T, M, R>) -> Self
Sets the selector function to be used when multiple rules are applicable to the same node.
See the morph method of the Engine type for more information.
Sourcepub fn add_cacher<Cache: RewriteCache<T>>(
self,
cacher: Cache,
) -> EngineBuilder<T, M, R, Cache>
pub fn add_cacher<Cache: RewriteCache<T>>( self, cacher: Cache, ) -> EngineBuilder<T, M, R, Cache>
Adds caching support to tree-morph.
Recommended to use [HashMapCache] as it has a concrete
implementation
Sourcepub fn set_parallel(self, parallel: bool) -> Self
pub fn set_parallel(self, parallel: bool) -> Self
Enables or disables parallel rule checking via Rayon.
When enabled, all rules are tested in parallel using par_iter.
Defaults to false.
Sourcepub fn set_discriminant_fn(
self,
discriminant_fn: Option<fn(&T) -> usize>,
) -> Self
pub fn set_discriminant_fn( self, discriminant_fn: Option<fn(&T) -> usize>, ) -> Self
Sets the discriminant function used for rule prefiltering.
When Some(f) is provided, f is called on each node to compute a unique usize id,
which is used to skip rules that do not apply to that node type.
When None, prefiltering is disabled and all rules are tried on every node.
Sourcepub fn set_fixedpoint(self, fixedpoint: bool) -> Self
pub fn set_fixedpoint(self, fixedpoint: bool) -> Self
Fixed-point application: after a rule fires, re-apply rules to the transformed node until no more rules match, before continuing traversal.
Sourcepub fn add_down_predicate(self, predicate: fn(&T) -> bool) -> Self
pub fn add_down_predicate(self, predicate: fn(&T) -> bool) -> Self
Adds a predicate that controls whether the engine descends into a node’s children.
Trait Implementations§
Source§impl<T, M, R> Default for EngineBuilder<T, M, R, NoCache>
impl<T, M, R> Default for EngineBuilder<T, M, R, NoCache>
Source§impl<T, M, R, C> From<EngineBuilder<T, M, R, C>> for Engine<T, M, R, C>
impl<T, M, R, C> From<EngineBuilder<T, M, R, C>> for Engine<T, M, R, C>
Source§fn from(val: EngineBuilder<T, M, R, C>) -> Self
fn from(val: EngineBuilder<T, M, R, C>) -> Self
Auto Trait Implementations§
impl<T, M, R, C> Freeze for EngineBuilder<T, M, R, C>where
C: Freeze,
impl<T, M, R, C> RefUnwindSafe for EngineBuilder<T, M, R, C>where
C: RefUnwindSafe,
R: RefUnwindSafe,
impl<T, M, R, C> Send for EngineBuilder<T, M, R, C>
impl<T, M, R, C> Sync for EngineBuilder<T, M, R, C>
impl<T, M, R, C> Unpin for EngineBuilder<T, M, R, C>
impl<T, M, R, C> UnsafeUnpin for EngineBuilder<T, M, R, C>where
C: UnsafeUnpin,
impl<T, M, R, C> UnwindSafe for EngineBuilder<T, M, R, C>where
C: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.