pub struct QueryCursor { /* private fields */ }
Implementations§
Source§impl QueryCursor
impl QueryCursor
Sourcepub const unsafe fn from_raw(ptr: *mut TSQueryCursor) -> Self
pub const unsafe fn from_raw(ptr: *mut TSQueryCursor) -> Self
Sourcepub fn into_raw(self) -> *mut TSQueryCursor
pub fn into_raw(self) -> *mut TSQueryCursor
Consumes the QueryCursor
, returning a raw pointer to the underlying C structure.
Source§impl QueryCursor
impl QueryCursor
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new cursor for executing a given query.
The cursor stores the state that is needed to iteratively search for matches.
Sourcepub fn match_limit(&self) -> u32
pub fn match_limit(&self) -> u32
Return the maximum number of in-progress matches for this cursor.
Sourcepub fn set_match_limit(&mut self, limit: u32)
pub fn set_match_limit(&mut self, limit: u32)
Set the maximum number of in-progress matches for this cursor. The limit must be > 0 and <= 65536.
Sourcepub fn set_timeout_micros(&mut self, timeout: u64)
pub fn set_timeout_micros(&mut self, timeout: u64)
Set the maximum duration in microseconds that query execution should be allowed to take before halting.
If query execution takes longer than this, it will halt early, returning None.
Sourcepub fn timeout_micros(&self) -> u64
pub fn timeout_micros(&self) -> u64
Get the duration in microseconds that query execution is allowed to take.
This is set via set_timeout_micros
.
Sourcepub fn did_exceed_match_limit(&self) -> bool
pub fn did_exceed_match_limit(&self) -> bool
Check if, on its last execution, this cursor exceeded its maximum number of in-progress matches.
Sourcepub fn matches<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
) -> QueryMatches<'query, 'tree, T, I>
pub fn matches<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, ) -> QueryMatches<'query, 'tree, T, I>
Iterate over all of the matches in the order that they were found.
Each match contains the index of the pattern that matched, and a list of captures. Because multiple patterns can match the same set of nodes, one match may contain captures that appear before some of the captures from a previous match.
Sourcepub fn captures<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>(
&'cursor mut self,
query: &'query Query,
node: Node<'tree>,
text_provider: T,
) -> QueryCaptures<'query, 'tree, T, I>
pub fn captures<'query, 'cursor: 'query, 'tree, T: TextProvider<I>, I: AsRef<[u8]>>( &'cursor mut self, query: &'query Query, node: Node<'tree>, text_provider: T, ) -> QueryCaptures<'query, 'tree, T, I>
Iterate over all of the individual captures in the order that they appear.
This is useful if you don’t care about which pattern matched, and just want a single, ordered sequence of captures.
Sourcepub fn set_byte_range(&mut self, range: Range<usize>) -> &mut Self
pub fn set_byte_range(&mut self, range: Range<usize>) -> &mut Self
Set the range in which the query will be executed, in terms of byte offsets.
Sourcepub fn set_point_range(&mut self, range: Range<Point>) -> &mut Self
pub fn set_point_range(&mut self, range: Range<Point>) -> &mut Self
Set the range in which the query will be executed, in terms of rows and columns.
Sourcepub fn set_max_start_depth(&mut self, max_start_depth: Option<u32>) -> &mut Self
pub fn set_max_start_depth(&mut self, max_start_depth: Option<u32>) -> &mut Self
Set the maximum start depth for a query cursor.
This prevents cursors from exploring children nodes at a certain depth. Note if a pattern includes many children, then they will still be checked.
The zero max start depth value can be used as a special behavior and it helps to destructure a subtree by staying on a node and using captures for interested parts. Note that the zero max start depth only limit a search depth for a pattern’s root node but other nodes that are parts of the pattern may be searched at any depth what defined by the pattern structure.
Set to None
to remove the maximum start depth.