sift_core/search/request/
mod.rs1use crate::Candidate;
2use crate::search::output::SearchOutput;
3use crate::search::output::style::SearchSeparators;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
6pub enum LinkTraversal {
7 #[default]
8 DoNotFollow,
9 Follow,
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
13pub struct WalkOptions {
14 pub links: LinkTraversal,
15 pub max_depth: Option<usize>,
16 pub max_filesize: Option<u64>,
17 pub one_file_system: bool,
18}
19
20#[derive(Clone)]
21pub struct SearchExecution<'a> {
22 pub candidates: &'a [Candidate],
23 pub output: SearchOutput,
24 pub separators: &'a SearchSeparators,
25 pub collect: SearchCollection,
26}
27
28#[must_use]
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31pub struct SearchCollection {
32 pub stats: bool,
33 pub hits: bool,
34}
35
36impl Default for SearchCollection {
37 fn default() -> Self {
38 Self::none()
39 }
40}
41
42impl SearchCollection {
43 pub const fn none() -> Self {
44 Self {
45 stats: false,
46 hits: false,
47 }
48 }
49
50 pub const fn stats() -> Self {
51 Self {
52 stats: true,
53 hits: false,
54 }
55 }
56
57 pub const fn hits() -> Self {
58 Self {
59 stats: false,
60 hits: true,
61 }
62 }
63
64 pub const fn stats_and_hits() -> Self {
65 Self {
66 stats: true,
67 hits: true,
68 }
69 }
70
71 pub const fn with_stats(self, stats: bool) -> Self {
72 Self {
73 stats,
74 hits: self.hits,
75 }
76 }
77
78 pub const fn with_hits(self, hits: bool) -> Self {
79 Self {
80 stats: self.stats,
81 hits,
82 }
83 }
84}