Skip to main content

Processor

Trait Processor 

Source
pub trait Processor {
    // Required methods
    fn get_name(&self) -> &str;
    fn process(&mut self, doc: PostDocument, nodes: Vec<Node>) -> ProcessResult;

    // Provided methods
    fn resource_directory(&self) -> Option<&str> { ... }
    fn resource_prefix(&self) -> Option<&str> { ... }
    fn to_process(&self, doc: &PostDocument) -> Vec<Node> { ... }
    fn desired_resource_pathname(
        &self,
        _doc: &PostDocument,
        _node: &Node,
        _source: Option<&str>,
        _type_ext: Option<&str>,
    ) -> Option<PathBuf> { ... }
    fn generate_resource_pathname(
        &self,
        doc: &mut PostDocument,
        _node: &Node,
        _source: Option<&str>,
        type_ext: Option<&str>,
    ) -> PathBuf { ... }
}
Expand description

Abstract base trait for all post-processors.

Corresponds to LaTeXML::Post::Processor. Processors operate on a PostDocument and return one or more documents (splitting may produce multiple outputs).

Required Methods§

Source

fn get_name(&self) -> &str

Human-readable name for this processor.

Source

fn process(&mut self, doc: PostDocument, nodes: Vec<Node>) -> ProcessResult

Process the document given the nodes returned by to_process. Returns the resulting document(s) — splitting may produce multiple.

Provided Methods§

Source

fn resource_directory(&self) -> Option<&str>

Resource directory for generated resources (images, etc.).

Source

fn resource_prefix(&self) -> Option<&str>

Resource prefix for generated resource filenames.

Source

fn to_process(&self, doc: &PostDocument) -> Vec<Node>

Return the nodes to be processed; by default the document element. This allows processors to focus on specific kinds of nodes, or to skip processing if there are none to process.

Source

fn desired_resource_pathname( &self, _doc: &PostDocument, _node: &Node, _source: Option<&str>, _type_ext: Option<&str>, ) -> Option<PathBuf>

Hint for a desired resource pathname.

Source

fn generate_resource_pathname( &self, doc: &mut PostDocument, _node: &Node, _source: Option<&str>, type_ext: Option<&str>, ) -> PathBuf

Auto-generate a unique resource pathname using a counter from the doc cache.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§