pub struct Query {
pub must: Vec<Matcher>,
pub should: Vec<Matcher>,
pub must_not: Vec<Matcher>,
}Expand description
A parsed search query with boolean semantics.
Fields§
§must: Vec<Matcher>All must match (AND).
should: Vec<Matcher>At least one must match (OR / default).
must_not: Vec<Matcher>None may match (NOT).
Implementations§
Source§impl Query
impl Query
Sourcepub fn matches_line(&self, line: &str) -> bool
pub fn matches_line(&self, line: &str) -> bool
Does this query match a given line?
Sourcepub fn matches_file(&self, content: &str) -> bool
pub fn matches_file(&self, content: &str) -> bool
Does this query match anywhere in a file’s content? For AND semantics: each must term appears somewhere in the file. For OR semantics: at least one should term appears somewhere. For NOT: no must_not term appears anywhere.
Sourcepub fn matching_lines(&self, content: &str) -> Vec<usize>
pub fn matching_lines(&self, content: &str) -> Vec<usize>
Find lines in content that match any positive term.
Used after matches_file confirms the file is relevant.
Sourcepub fn simple_regex(&self) -> Option<&Regex>
pub fn simple_regex(&self) -> Option<&Regex>
Get the single regex for simple queries.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnsafeUnpin for Query
impl UnwindSafe for Query
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more