Skip to main content

OutputFormatter

Trait OutputFormatter 

Source
pub trait OutputFormatter {
    // Required methods
    fn format_result(&self, result: &GrepResult) -> Result<String>;
    fn format_results(&self, results: &[GrepResult]) -> Result<String>;

    // Provided methods
    fn print_result(&self, result: &GrepResult) -> Result<()> { ... }
    fn print_results(&self, results: &[GrepResult]) -> Result<()> { ... }
}
Expand description

Trait for output formatters

Required Methods§

Source

fn format_result(&self, result: &GrepResult) -> Result<String>

Format a single grep result

Source

fn format_results(&self, results: &[GrepResult]) -> Result<String>

Format multiple grep results

Provided Methods§

Source

fn print_result(&self, result: &GrepResult) -> Result<()>

Print a result directly to stdout

Source

fn print_results(&self, results: &[GrepResult]) -> Result<()>

Print multiple results directly to stdout

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§