Skip to main content

sift_core/index/
config.rs

1use std::path::{Path, PathBuf};
2
3use serde::{Deserialize, Serialize};
4
5use crate::search::filter::VisibilityConfig;
6
7/// Whether the index was built from a directory or a single file.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
9pub enum CorpusKind {
10    /// Built from a directory path — all discovered files were indexed.
11    #[default]
12    Directory,
13    /// Built from a single file path — only that file was indexed.
14    SingleFile,
15}
16
17/// Filesystem walk behavior for index builds and updates.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
19pub struct IndexWalkConfig {
20    pub follow_links: bool,
21    pub one_file_system: bool,
22    pub max_depth: Option<usize>,
23    pub max_filesize: Option<u64>,
24}
25
26impl IndexWalkConfig {
27    #[must_use]
28    pub const fn new(follow_links: bool) -> Self {
29        Self {
30            follow_links,
31            one_file_system: false,
32            max_depth: None,
33            max_filesize: None,
34        }
35    }
36}
37
38/// Configuration for building or updating an index over a corpus.
39pub struct IndexConfig<'a> {
40    pub corpus: CorpusSpec<'a>,
41    pub walk: IndexWalkConfig,
42    pub visibility: VisibilityConfig,
43}
44
45/// Description of a corpus to index.
46pub struct CorpusSpec<'a> {
47    pub root: &'a Path,
48    pub kind: CorpusKind,
49    pub follow_links: bool,
50    pub include_paths: &'a [PathBuf],
51    pub exclude_paths: &'a [PathBuf],
52}