use crate::core::{Position, Range};
#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::{string::String, vec::Vec};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SearchOptions {
pub case_sensitive: bool,
pub whole_words: bool,
pub max_results: usize,
pub use_regex: bool,
pub scope: SearchScope,
}
impl Default for SearchOptions {
fn default() -> Self {
Self {
case_sensitive: false,
whole_words: false,
max_results: 100,
use_regex: false,
scope: SearchScope::All,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SearchScope {
All,
Lines { start: usize, end: usize },
Sections(Vec<String>),
Range(Range),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SearchResult<'a> {
pub start: Position,
pub end: Position,
pub text: Cow<'a, str>,
pub context: Cow<'a, str>,
pub line: usize,
pub column: usize,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SearchStats {
pub match_count: usize,
pub search_time_us: u64,
pub hit_limit: bool,
pub index_size: usize,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SearchError {
InvalidRegex { pattern: String, error: String },
IndexCorrupted,
FeatureNotAvailable { feature: String },
Timeout { duration_ms: u64 },
}