macro_rules! impl_filter_step {
($step:ty, $name:literal) => { ... };
}Expand description
Helper macro to implement Step for simple filter steps.
Filter steps pass through or reject traversers based on a predicate. The step struct must:
- Implement
Clone - Have a
matches(&self, ctx: &ExecutionContext, traverser: &Traverser) -> boolmethod
§Example
ⓘ
#[derive(Clone)]
struct IsPositiveStep;
impl IsPositiveStep {
fn matches(&self, _ctx: &ExecutionContext, traverser: &Traverser) -> bool {
matches!(&traverser.value, Value::Int(n) if *n > 0)
}
}
impl_filter_step!(IsPositiveStep, "isPositive");§Streaming Support
For streaming execution, filter steps using this macro must also implement
matches_streaming(&self, ctx: &StreamingContext, traverser: &Traverser) -> bool.
If you don’t need streaming support yet, the macro provides a default pass-through
that can be overridden by also implementing matches_streaming.