pub struct PreparedScanner { /* private fields */ }Expand description
Scan options with their policy regular expressions compiled once.
A scanner can be shared between threads. Embedded language scanners (HTML script/style bodies, Markdown fences, Vue and Svelte regions) reuse the same compiled pattern sets as their parent.
Implementations§
Source§impl PreparedScanner
impl PreparedScanner
Sourcepub fn scan_profile(
&self,
source: &[u8],
profile: &DeclarativeProfile,
) -> Result<ScanReport, ProfileError>
pub fn scan_profile( &self, source: &[u8], profile: &DeclarativeProfile, ) -> Result<ScanReport, ProfileError>
Scan a declarative profile with this scanner’s already-compiled policy.
Sourcepub fn transform_profile_plan(
&self,
source: &[u8],
profile: &DeclarativeProfile,
layout: Layout,
) -> Result<TransformPlan, ProfileError>
pub fn transform_profile_plan( &self, source: &[u8], profile: &DeclarativeProfile, layout: Layout, ) -> Result<TransformPlan, ProfileError>
Plan a declarative-profile transformation without materializing its output bytes or source map.
Source§impl PreparedScanner
impl PreparedScanner
Sourcepub fn new(options: ScanOptions) -> Result<Self, Error>
pub fn new(options: ScanOptions) -> Result<Self, Error>
Compile the policy patterns in options for reuse across any number of
source files.
Sourcepub fn options(&self) -> &ScanOptions
pub fn options(&self) -> &ScanOptions
The effective options this scanner was prepared from.
Sourcepub fn scan(&self, source: &[u8], language: Language) -> ScanReport
pub fn scan(&self, source: &[u8], language: Language) -> ScanReport
Scan one source without recompiling its policy regular expressions.
Source§impl PreparedScanner
impl PreparedScanner
Sourcepub fn transform_plan(
&self,
source: &[u8],
language: Language,
layout: Layout,
) -> TransformPlan
pub fn transform_plan( &self, source: &[u8], language: Language, layout: Layout, ) -> TransformPlan
Scan and plan edits with this scanner’s already-compiled policy.
Sourcepub fn transform(
&self,
source: &[u8],
language: Language,
layout: Layout,
) -> TransformResult
pub fn transform( &self, source: &[u8], language: Language, layout: Layout, ) -> TransformResult
Produce a complete transformation with this scanner’s compiled policy.
Sourcepub fn transform_spans_plan(
&self,
source: &[u8],
language: Language,
spans: &[(ByteSpan, CommentKind)],
layout: Layout,
) -> Result<TransformPlan, ExternalSpanError>
pub fn transform_spans_plan( &self, source: &[u8], language: Language, spans: &[(ByteSpan, CommentKind)], layout: Layout, ) -> Result<TransformPlan, ExternalSpanError>
Validate externally supplied spans and plan their edits with this scanner’s already-compiled policy.
Sourcepub fn scan_spans(
&self,
source: &[u8],
language: Language,
spans: &[(ByteSpan, CommentKind)],
) -> Result<ScanReport, ExternalSpanError>
pub fn scan_spans( &self, source: &[u8], language: Language, spans: &[(ByteSpan, CommentKind)], ) -> Result<ScanReport, ExternalSpanError>
Validate and classify externally supplied spans without planning edits.
Trait Implementations§
Source§impl Clone for PreparedScanner
impl Clone for PreparedScanner
Source§fn clone(&self) -> PreparedScanner
fn clone(&self) -> PreparedScanner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more