Skip to main content

PluginRegistrar

Trait PluginRegistrar 

Source
pub trait PluginRegistrar {
    // Required methods
    fn highlighter(&mut self, factory: HighlighterFactory);
    fn code_highlighter(
        &mut self,
        name: &str,
        highlighter: Arc<dyn CodeHighlighter>,
    );
    fn theme(&mut self, name: &str, theme: Theme);
    fn box_style(&mut self, name: &str, style: BoxStyle);
    fn renderer(&mut self, name: &str, renderer: Arc<dyn SourceRenderer>);
    fn fence_renderer(
        &mut self,
        language: &str,
        renderer: Arc<dyn FenceRenderer>,
    );
    fn transform(&mut self, name: &str, transform: Arc<dyn TextTransform>);

    // Provided methods
    fn action(&mut self, name: &str, action: Arc<dyn CustomAction>) { ... }
    fn component(&mut self, name: &str, factory: ComponentFactory) { ... }
}
Expand description

What a plugin can add. Plugin::register receives one of these.

Names are checked by the host when register returns: they must be non-empty and use lowercase letters, digits, -, _ and ., and two plugins may not register the same capability under the same name.

Required Methods§

Source

fn highlighter(&mut self, factory: HighlighterFactory)

A regex highlighter applied to printed text.

Source

fn code_highlighter( &mut self, name: &str, highlighter: Arc<dyn CodeHighlighter>, )

A syntax-highlighting engine, selectable by name.

Source

fn theme(&mut self, name: &str, theme: Theme)

A named theme.

Source

fn box_style(&mut self, name: &str, style: BoxStyle)

A named table/panel box style.

Source

fn renderer(&mut self, name: &str, renderer: Arc<dyn SourceRenderer>)

A named source renderer.

Source

fn fence_renderer(&mut self, language: &str, renderer: Arc<dyn FenceRenderer>)

A renderer for Markdown fences whose language is language (for example "mermaid"), used in place of highlighting them as code.

Source

fn transform(&mut self, name: &str, transform: Arc<dyn TextTransform>)

A named text transform.

Provided Methods§

Source

fn action(&mut self, name: &str, action: Arc<dyn CustomAction>)

A named custom action for interactive views. A host without them ignores it, which is the default.

Source

fn component(&mut self, name: &str, factory: ComponentFactory)

A named interactive component (see component): a view an app or the CLI mounts by name, beside the built-in components. factory makes a fresh one for every mount. A host without interactive views ignores it, which is the default.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§