Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn process_line(
        &mut self,
        line: &str,
        state: &ParseState,
        style: &ComputedStyle,
    ) -> Option<ProcessResult>;
    fn flush(&mut self) -> Option<Vec<String>>;
    fn reset(&mut self);

    // Provided methods
    fn priority(&self) -> i32 { ... }
    fn is_active(&self) -> bool { ... }
}
Expand description

Plugin trait for custom content processors.

Plugins intercept input lines and can:

  • Transform them into different output
  • Buffer multiple lines before emitting
  • Pass through to normal processing

Required Methods§

Source

fn name(&self) -> &str

Plugin name for identification and logging.

Source

fn process_line( &mut self, line: &str, state: &ParseState, style: &ComputedStyle, ) -> Option<ProcessResult>

Process a line of input.

§Returns
  • None: Plugin not interested, continue normal processing
  • Some(ProcessResult::Lines(vec)): Emit these lines instead
  • Some(ProcessResult::Continue): Plugin consumed input, keep buffering
Source

fn flush(&mut self) -> Option<Vec<String>>

Called when stream ends to flush any buffered content.

§Returns
  • None: Nothing to flush
  • Some(vec): Remaining buffered lines to emit
Source

fn reset(&mut self)

Reset plugin state.

Called when starting a new document or clearing state.

Provided Methods§

Source

fn priority(&self) -> i32

Plugin priority (lower = higher priority).

Default is 0. Plugins with lower priority numbers are called first.

Source

fn is_active(&self) -> bool

Whether this plugin is currently active (buffering).

Active plugins get priority for subsequent lines.

Implementors§