sel/matcher/mod.rs
1//! Matcher stage — decides whether a given line is a hit.
2
3pub mod lines;
4pub mod position;
5pub mod regex;
6
7pub use self::regex::RegexMatcher;
8pub use lines::LineMatcher;
9pub use position::PositionMatcher;
10
11use crate::{Line, MatchInfo};
12
13/// Classifies each line as hit or miss.
14///
15/// Implementations may be stateful (e.g., a position matcher that advances
16/// through a sorted list of targets).
17pub trait Matcher {
18 fn match_line(&mut self, line: &Line) -> MatchInfo;
19}
20
21/// A matcher that hits every line.
22pub struct AllMatcher;
23
24impl Matcher for AllMatcher {
25 fn match_line(&mut self, _line: &Line) -> MatchInfo {
26 MatchInfo {
27 hit: true,
28 ..MatchInfo::default()
29 }
30 }
31}