Skip to main content

Transform

Trait Transform 

Source
pub trait Transform {
    // Required methods
    fn name(&self) -> &str;
    fn transform(&self, root: &mut Root, source: &str);
}
Expand description

A transform that operates on an RDX AST in place.

Implement this trait to create custom RDX plugins. Transforms receive a mutable reference to the full document root and the original source text.

§Example

use rdx_transform::{Transform, Root};

struct MyPlugin;

impl Transform for MyPlugin {
    fn name(&self) -> &str { "my-plugin" }
    fn transform(&self, root: &mut Root, _source: &str) {
        // modify the AST
    }
}

Required Methods§

Source

fn name(&self) -> &str

A short identifier for this transform (used in error messages / debugging).

Source

fn transform(&self, root: &mut Root, source: &str)

Apply the transform to the AST. source is the original document text, available for transforms that need to reference raw content.

Implementors§