Skip to main content

lb_rs/search/
mod.rs

1pub mod content;
2pub mod path;
3
4use std::ops::Range;
5use uuid::Uuid;
6
7pub use content::ContentSearcher;
8pub use path::PathSearcher;
9
10/// Unified search result for both path and content searches.
11#[derive(Debug, Clone, Default)]
12pub struct SearchResult {
13    pub id: Uuid,
14    pub filename: String,
15    pub parent_path: String,
16    /// Character indices in the full path that matched (for path search highlighting).
17    pub path_indices: Vec<u32>,
18    pub path_matches: Vec<ContentMatch>,
19    /// Content matches within the document.
20    pub content_matches: Vec<ContentMatch>,
21}
22
23/// A match highlight within document content.
24#[derive(Debug, Clone)]
25pub struct ContentMatch {
26    /// Byte range into the document content.
27    pub range: Range<usize>,
28    /// Whether this is an exact match of the full query.
29    pub exact: bool,
30}
31
32use crate::Lb;
33
34impl Lb {
35    pub async fn path_searcher(&self) -> PathSearcher {
36        PathSearcher::new(self).await
37    }
38}