pub struct QueryRun<'a> {
pub start: usize,
pub end: Option<usize>,
/* private fields */
}Expand description
A query run is a slice of query tokens identified by a start and end positions.
Query runs break a query into manageable chunks for efficient matching. They track matchable token positions and support subtraction of matched spans.
Based on Python QueryRun class at: reference/scancode-toolkit/src/licensedcode/query.py (lines 720-914)
Fields§
§start: usize§end: Option<usize>Implementations§
Source§impl<'a> QueryRun<'a>
impl<'a> QueryRun<'a>
Sourcepub fn new(query: &'a Query<'a>, start: usize, end: Option<usize>) -> Self
pub fn new(query: &'a Query<'a>, start: usize, end: Option<usize>) -> Self
Create a new query run from a query with start and end positions.
§Arguments
query- The parent querystart- The start position (inclusive)end- The end position (inclusive), or None for an empty run
Corresponds to Python: QueryRun.__init__() (lines 735-749)
Sourcepub fn get_index(&self) -> &LicenseIndex
pub fn get_index(&self) -> &LicenseIndex
Get the license index used by this query run.
Sourcepub fn line_for_pos(&self, pos: usize) -> Option<usize>
pub fn line_for_pos(&self, pos: usize) -> Option<usize>
Sourcepub fn tokens(&self) -> &[TokenId]
pub fn tokens(&self) -> &[TokenId]
Get the sequence of token IDs for this run.
Returns empty slice if end is None.
Corresponds to Python: tokens property (lines 779-786)
Sourcepub fn tokens_with_pos(&self) -> impl Iterator<Item = (usize, TokenId)> + '_
pub fn tokens_with_pos(&self) -> impl Iterator<Item = (usize, TokenId)> + '_
Iterate over token IDs with their absolute positions.
Corresponds to Python: tokens_with_pos() method (lines 788-789)
Sourcepub fn is_digits_only(&self) -> bool
pub fn is_digits_only(&self) -> bool
Check if this query run contains only digit tokens.
Corresponds to Python: is_digits_only() method (lines 791-796)
Sourcepub fn is_matchable(
&self,
include_low: bool,
exclude_positions: &[PositionSpan],
) -> bool
pub fn is_matchable( &self, include_low: bool, exclude_positions: &[PositionSpan], ) -> bool
Check if this query run has matchable tokens.
§Arguments
include_low- If true, include low-value tokens in the checkexclude_positions- Optional set of spans containing positions to exclude
Returns true if there are matchable tokens remaining
Corresponds to Python: is_matchable() method (lines 798-818)
pub fn matchables(&self, include_low: bool) -> BitSet
pub fn matchable_tokens(&self) -> Vec<i32>
pub fn high_matchables(&self) -> BitSet
pub fn low_matchables(&self) -> BitSet
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for QueryRun<'a>
impl<'a> !RefUnwindSafe for QueryRun<'a>
impl<'a> Send for QueryRun<'a>
impl<'a> !Sync for QueryRun<'a>
impl<'a> Unpin for QueryRun<'a>
impl<'a> UnsafeUnpin for QueryRun<'a>
impl<'a> UnwindSafe for QueryRun<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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