Skip to main content

ass_editor/utils/indexing/
mod.rs

1//! FST-based search indexing for fast ASS content queries
2//!
3//! Provides trie-based indexing for regex and fuzzy search queries as specified
4//! in the architecture (lines 142-143). Fallback to linear search for WASM.
5
6mod common;
7mod linear;
8
9#[cfg(feature = "search-index")]
10mod fst;
11#[cfg(feature = "search-index")]
12mod fst_build;
13#[cfg(feature = "search-index")]
14mod fst_search;
15
16#[cfg(test)]
17mod tests;
18
19pub use common::IndexEntry;
20pub use linear::LinearSearchIndex;
21
22#[cfg(feature = "search-index")]
23pub use fst::FstSearchIndex;
24
25use crate::utils::search::DocumentSearch;
26
27#[cfg(not(feature = "std"))]
28use alloc::boxed::Box;
29
30/// Factory function to create the appropriate search index
31pub fn create_search_index() -> Box<dyn DocumentSearch> {
32    #[cfg(feature = "search-index")]
33    {
34        Box::new(FstSearchIndex::new())
35    }
36    #[cfg(not(feature = "search-index"))]
37    {
38        Box::new(LinearSearchIndex::new())
39    }
40}