Skip to main content

OutputFormatter

Trait OutputFormatter 

Source
pub trait OutputFormatter {
    // Required method
    fn on_event(&self, event: BuildEvent) -> Result<(), PluginError>;

    // Provided method
    fn finalize(&self) -> Result<Vec<u8>, PluginError> { ... }
}
Expand description

Implemented by output-formatter plugins.

The host invokes OutputFormatter::on_event for every build event in order, then once at the end calls OutputFormatter::finalize for formatters that accumulate (JUnit XML, JSON arrays).

Required Methods§

Source

fn on_event(&self, event: BuildEvent) -> Result<(), PluginError>

Handle a single build event.

§Errors

Returns a PluginError if the formatter cannot process the event (e.g. malformed input). The host renders the error and aborts the formatter; the build itself is unaffected.

Provided Methods§

Source

fn finalize(&self) -> Result<Vec<u8>, PluginError>

Optional. Default returns empty bytes. Streaming formatters (human, json-lines) leave this alone; accumulating formatters (junit) return the full document here.

§Errors

Returns a PluginError if the formatter cannot serialise its accumulated state.

Implementors§