1use std::fmt::{Display, Error, Formatter};
2use std::sync::Arc;
3
4use crate::item::RankBuilder;
5use crate::{MatchEngine, MatchRange, MatchResult, SkimItem};
6
7#[derive(Debug)]
9pub struct MatchAllEngine {
10 rank_builder: Arc<RankBuilder>,
11}
12
13impl MatchAllEngine {
14 pub fn builder() -> Self {
15 Self {
16 rank_builder: Default::default(),
17 }
18 }
19
20 pub fn rank_builder(mut self, rank_builder: Arc<RankBuilder>) -> Self {
21 self.rank_builder = rank_builder;
22 self
23 }
24
25 pub fn build(self) -> Self {
26 self
27 }
28}
29
30impl MatchEngine for MatchAllEngine {
31 fn match_item(&self, item: &dyn SkimItem, item_idx: usize) -> Option<MatchResult> {
32 let item_len = item.text().len();
33 Some(MatchResult {
34 rank: self.rank_builder.build_rank(0, 0, 0, item_len, item_idx),
35 matched_range: MatchRange::ByteRange(0, 0),
36 })
37 }
38}
39
40impl Display for MatchAllEngine {
41 fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
42 write!(f, "Noop")
43 }
44}