Skip to main content

orbok_core/
search_scope.rs

1//! Which files a search may return (RFC-060 §7).
2//!
3//! Plain data, shared by the query layer (`orbok-db` builds the SQL) and
4//! the search engine (`orbok-search` fills it in from the UI's filters and
5//! chosen folder). Both halves must agree, and a scope applied anywhere
6//! but the query is not a scope: post-filtering shrinks the result set
7//! below the requested limit and makes "no results" ambiguous
8//! (RFC-041 §25.5).
9
10/// One folder restriction: a registered source, and whether nested
11/// folders count.
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub struct FolderScope {
14    pub source_id: String,
15    /// `false` restricts to files sitting directly in the folder
16    /// (RFC-045 §6.3's "folder only").
17    pub include_subfolders: bool,
18}
19
20/// The scope of one search. Empty means unrestricted.
21#[derive(Debug, Clone, Default, PartialEq, Eq)]
22pub struct SearchScope {
23    /// Lowercased file extensions, without the dot. Empty means every
24    /// kind; the UI's kind filters expand to these.
25    pub extensions: Vec<String>,
26    pub folder: Option<FolderScope>,
27}
28
29impl SearchScope {
30    /// Whether this scope restricts anything at all.
31    pub fn is_unrestricted(&self) -> bool {
32        self.extensions.is_empty() && self.folder.is_none()
33    }
34}