Skip to main content

OutputAdapter

Trait OutputAdapter 

Source
pub trait OutputAdapter: Send + Sync {
    // Required methods
    fn print(&mut self, result: PrintResult) -> ValueWord;
    fn clone_box(&self) -> Box<dyn OutputAdapter>;

    // Provided method
    fn print_content_html(&mut self, _html: String) { ... }
}
Expand description

Trait for handling print() output

Different execution modes can provide different adapters:

  • Scripts: StdoutAdapter (print and discard spans)
  • REPL: ReplAdapter (print and preserve spans for reformatting)
  • Tests: MockAdapter (capture output)

Required Methods§

Source

fn print(&mut self, result: PrintResult) -> ValueWord

Handle print() output

§Arguments
  • result - The PrintResult with rendered string and spans
§Returns

The value to return from print() (Unit for scripts, PrintResult for REPL)

Source

fn clone_box(&self) -> Box<dyn OutputAdapter>

Clone the adapter (for trait object cloning)

Provided Methods§

Source

fn print_content_html(&mut self, _html: String)

Handle Content HTML from printing a Content value. Default implementation does nothing (terminal adapters don’t need HTML).

Trait Implementations§

Source§

impl Clone for Box<dyn OutputAdapter>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§