Query

Trait Query 

Source
pub trait Query {
    type Match<'query, 'tree: 'query>: QueryMatch<'query, 'tree>;
    type Capture<'query, 'tree: 'query>: QueryCapture<'query, 'tree>;

    // Required methods
    fn as_str(&self) -> &'static str;
    fn raw(&self) -> &'static Query;
    unsafe fn wrap_match<'query, 'tree>(
        &self,
        match: QueryMatch<'query, 'tree>,
    ) -> Self::Match<'query, 'tree>;
    unsafe fn wrap_match_ref<'m, 'query, 'tree>(
        &self,
        match: &'m QueryMatch<'query, 'tree>,
    ) -> &'m Self::Match<'query, 'tree>;
    unsafe fn wrap_capture<'query, 'tree: 'query>(
        &self,
        capture: QueryCapture<'tree>,
    ) -> Self::Capture<'query, 'tree>;
}
Expand description

A query which can generate type-safe matches and captures, which contain typed nodes

Required Associated Types§

Source

type Match<'query, 'tree: 'query>: QueryMatch<'query, 'tree>

A match of this typed query (runtime pattern index)

Source

type Capture<'query, 'tree: 'query>: QueryCapture<'query, 'tree>

An capture of this typed query (runtime capture index)

Required Methods§

Source

fn as_str(&self) -> &'static str

The string used to generate this query

Source

fn raw(&self) -> &'static Query

The underlying tree-sitter Query

Source

unsafe fn wrap_match<'query, 'tree>( &self, match: QueryMatch<'query, 'tree>, ) -> Self::Match<'query, 'tree>

Wrap a tree-sitter QueryMatch which you know came from this query.

§Safety

The match must have come from this query.

Source

unsafe fn wrap_match_ref<'m, 'query, 'tree>( &self, match: &'m QueryMatch<'query, 'tree>, ) -> &'m Self::Match<'query, 'tree>

Wrap a reference to a tree-sitter QueryMatch which you know came from this query.

§Safety

The match must have come from this query.

Source

unsafe fn wrap_capture<'query, 'tree: 'query>( &self, capture: QueryCapture<'tree>, ) -> Self::Capture<'query, 'tree>

Wrap a tree-sitter QueryCapture which you know came from this query.

§Safety

The capture must have come from this query.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§