Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Sized {
    type Options: DeserializeOwned;

    // Required methods
    fn new(options: Self::Options) -> Result<Self>;
    fn classify(&self, file: &FileEntry) -> Result<Vec<String>>;
    fn mutate(
        &self,
        file: &FileEntry,
        sides: &Pairing<Source>,
    ) -> Result<Vec<Move>>;

    // Provided methods
    fn queries(&self) -> Result<Vec<QuerySource>> { ... }
    fn enrich(
        &self,
        _file: &FileEntry,
        _sides: &Pairing<Source>,
    ) -> Result<Vec<Annotation>> { ... }
}
Expand description

A diffr plugin: the plugin resource of wit/plugin.wit. diffr makes one with Plugin::new when it builds its pipeline, before any file, and calls that one instance for every file of the run.

Required Associated Types§

Source

type Options: DeserializeOwned

The plugin’s options, deserialized from its bundled or external config entry: a JSON object, validated against the options schema in plugin.toml and filled with its defaults.

Required Methods§

Source

fn new(options: Self::Options) -> Result<Self>

Make the plugin from its options. An error, like options that do not deserialize, is a setup error naming the plugin.

Source

fn classify(&self, file: &FileEntry) -> Result<Vec<String>>

Tags to add to the file’s manifest entry before it is diffed. A plugin that does not classify returns none.

Source

fn mutate(&self, file: &FileEntry, sides: &Pairing<Source>) -> Result<Vec<Move>>

The moves that shape how the diffed file starts out. sides are the sides the file has, already rebuilt as trees.

Provided Methods§

Source

fn queries(&self) -> Result<Vec<QuerySource>>

Named query text, collected once during setup and compiled by diffr.

Source

fn enrich( &self, _file: &FileEntry, _sides: &Pairing<Source>, ) -> Result<Vec<Annotation>>

Deferred labels for stable region IDs, after all initial mutations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§