[][src]Trait dprint_core::plugins::Plugin

pub trait Plugin: Sync {
    fn name(&self) -> &'static str;
fn version(&self) -> &'static str;
fn config_keys(&self) -> Vec<String>;
fn initialize(
        &mut self,
        plugin_config: HashMap<String, String>,
        global_config: &GlobalConfiguration
    );
fn should_format_file(&self, file_path: &PathBuf, file_text: &str) -> bool;
fn get_resolved_config(&self) -> String;
fn get_configuration_diagnostics(&self) -> &Vec<ConfigurationDiagnostic>;
fn format_text(
        &self,
        file_path: &PathBuf,
        file_text: &str
    ) -> Result<String, String>; }

Plugin that can be implemented for use in the CLI.

Required methods

fn name(&self) -> &'static str

The name of the plugin.

fn version(&self) -> &'static str

The version of the plugin.

fn config_keys(&self) -> Vec<String>

Gets the possible keys that can be used in the configuration JSON.

fn initialize(
    &mut self,
    plugin_config: HashMap<String, String>,
    global_config: &GlobalConfiguration
)

Initializes the plugin.

fn should_format_file(&self, file_path: &PathBuf, file_text: &str) -> bool

Gets whether the specified file should be formatted.

fn get_resolved_config(&self) -> String

Gets the configuration as a collection of key value pairs.

fn get_configuration_diagnostics(&self) -> &Vec<ConfigurationDiagnostic>

Gets the configuration diagnostics.

fn format_text(
    &self,
    file_path: &PathBuf,
    file_text: &str
) -> Result<String, String>

Formats the text in memory based on the file path and file text.

Loading content...

Implementors

Loading content...