Skip to main content

TransformPlugin

Trait TransformPlugin 

Source
pub trait TransformPlugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn matches(&self, path: &str, source: &str) -> bool;
    fn transform(
        &self,
        source: &str,
        path: &str,
        ctx: &TransformContext,
    ) -> Option<String>;

    // Provided method
    fn priority(&self) -> u32 { ... }
}
Expand description

A plugin that hooks into the source-code transform pipeline.

Compile-time only — no WASM overhead on every file.

Built-in transforms run at priorities 100–700. Plugin transforms default to priority 1000 (after all built-ins). Lower priority runs first.

Required Methods§

Source

fn name(&self) -> &str

Unique identifier (e.g., "my-macro-expansion").

Source

fn matches(&self, path: &str, source: &str) -> bool

Return true if this plugin should process the file at path. Called before transform() to skip unnecessary work.

Source

fn transform( &self, source: &str, path: &str, ctx: &TransformContext, ) -> Option<String>

Transform the source code.

Returns Some(new_source) if modified, None if unchanged. Receives the current source which may already be modified by earlier transforms in the pipeline.

Provided Methods§

Source

fn priority(&self) -> u32

Execution priority. Lower runs first. Default: 1000 (after built-ins).

Implementors§