Skip to main content

Printer

Trait Printer 

Source
pub trait Printer {
    // Required methods
    fn out<T: Display + Serialize>(&mut self, data: T) -> Result<()>;
    fn event<T: Display + Serialize>(&mut self, event: T) -> Result<()>;
    fn out_bytes(&mut self, bytes: Bytes) -> Result<()>;

    // Provided method
    fn is_json(&self) -> bool { ... }
}
Available on crate feature terminal only.
Expand description

Sink a command writes its output to.

Required Methods§

Source

fn out<T: Display + Serialize>(&mut self, data: T) -> Result<()>

Writes the result of the command, as text or JSON.

Source

fn event<T: Display + Serialize>(&mut self, event: T) -> Result<()>

Writes an event, something the command observed while running, before its result.

An event serializes as an object whose root carries event, a kebab-case name, which a result never carries.

Source

fn out_bytes(&mut self, bytes: Bytes) -> Result<()>

Writes bytes as the result of the command: verbatim in text mode, as a Bytes object under JSON.

Provided Methods§

Source

fn is_json(&self) -> bool

Whether the printer emits JSON.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§