pub trait OutputAdapter: Send + Sync {
// Required methods
fn print(&mut self, result: PrintResult) -> KindedSlot;
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(preserve spans for reformatting) - Tests:
MockAdapter(capture output) - Hosts (server / notebook):
SharedCaptureAdapter
Required Methods§
Sourcefn print(&mut self, result: PrintResult) -> KindedSlot
fn print(&mut self, result: PrintResult) -> KindedSlot
Handle print() output.
Returns the value that print() yields. Scripts return
KindedSlot::none(); REPL adapters MAY surface the
PrintResult via a future typed-schema heap value but currently
also return none() until that schema lands.
Sourcefn clone_box(&self) -> Box<dyn OutputAdapter>
fn clone_box(&self) -> Box<dyn OutputAdapter>
Clone the adapter (for trait object cloning)
Provided Methods§
Sourcefn print_content_html(&mut self, _html: String)
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".