pub struct CompiledExtraction { /* private fields */ }Expand description
A pre-compiled extraction that can be reused across multiple source inputs.
Stores compiled tree_sitter::Query objects and their capture names so they
don’t need to be recompiled for every call. A QueryCursor is reused across
patterns within a single extraction call, making this type Send + Sync.
Implementations§
Source§impl CompiledExtraction
impl CompiledExtraction
Sourcepub fn compile(config: &ExtractionConfig) -> Result<Self, Error>
pub fn compile(config: &ExtractionConfig) -> Result<Self, Error>
Compile an extraction config for repeated use.
§Errors
Returns an error if the language is not found or any query pattern is invalid.
Sourcepub fn compile_with_language(
language: Language,
language_name: &str,
extraction_patterns: &AHashMap<String, ExtractionPattern>,
) -> Result<Self, Error>
pub fn compile_with_language( language: Language, language_name: &str, extraction_patterns: &AHashMap<String, ExtractionPattern>, ) -> Result<Self, Error>
Compile extraction patterns using a pre-loaded tree_sitter::Language.
This avoids a redundant language registry lookup when the caller already has the language (e.g., from an earlier parse step).
§Errors
Returns an error if any query pattern is invalid.
Sourcepub fn extract(&self, source: &str) -> Result<ExtractionResult, Error>
pub fn extract(&self, source: &str) -> Result<ExtractionResult, Error>
Extract from source code, parsing it first.
Uses the thread-local parser cache to avoid creating a new parser on every call.
§Errors
Returns an error if parsing fails.