Struct calypso_base::ui::Emitter

source ·
pub struct Emitter {
    writer: BufferWriter,
    buf: Buffer,
}
Expand description

A structure handling emitting messages to the terminal. This Derefs and DerefMuts to a termcolor::Buffer, so you can use termcolor::WriteColor and methods on Buffer to write custom text.

Note that text is never automatically flushed, so you must manually use Emitter::flush.

Fields§

§writer: BufferWriter§buf: Buffer

Implementations§

Create a new emitter.

Create a new buffer based on the color preferences of this emitter.

Flush the emitter. This will clear the internal buffer.

Errors

This function will error if the emitter could not print the contents of the internal buffer.

Add a newline to the internal buffer.

Errors

This function will error if the buffer could not be updated.

Add the string provided to the internal buffer verbatim. (Chainable)

Errors

This function will error if the buffer could not be updated.

Emit an error. Note that this function will reset the existing color of the internal buffer. The emitted text will have a newline.

Forms

Angle brackets (<>) indicate a string provided to the function.

Without code or message
error: <short>
With code but not message
error[<code>]: <short>
With message but not code
error: <short>: <message>
With code and message
error[<code>]: <short>: <message>
Color

When color is enabled for the output provided, the segments will be colored as such:

  • error[<code>]: Red; bold, intense
  • <short>: White; bold, intense
  • <message>: Default color
Errors

This function will error if at any point text could not be written to the internal buffer.

Emit an informational message. Note that this function will reset the existing color of the internal buffer. The emitted text will have a newline.

Forms

Angle brackets (<>) indicate a string provided to the function.

Without message
info: <short>
With message
info: <short>: <message>
Color

When color is enabled for the output provided, the segments will be colored as such:

  • info: Cyan; bold, intense
  • <short>: White; bold, intense
  • <message>: Default color
Errors

This function will error if at any point text could not be written to the internal buffer.

Emit a note. Note that this function will reset the existing color of the internal buffer. The emitted text will have a newline.

Forms

Angle brackets (<>) indicate a string provided to the function.

Without message
note: <short>
With message
note: <short>: <message>
Color

When color is enabled for the output provided, the segments will be colored as such:

  • note: Green; bold, intense
  • <short>: White; bold, intense
  • <message>: Default color
Errors

This function will error if at any point text could not be written to the internal buffer.

Emit a warning. Note that this function will reset the existing color of the internal buffer. The emitted text will have a newline.

Forms

Angle brackets (<>) indicate a string provided to the function.

Without message
warn: <short>
With message
warn: <short>: <message>
Color

When color is enabled for the output provided, the segments will be colored as such:

  • warn: Yellow; bold, intense
  • <short>: White; bold, intense
  • <message>: Default color
Errors

This function will error if at any point text could not be written to the internal buffer.

Emit a Buffer now.

Since we can’t merge buffers (see termcolor#45), this function directly prints the buffer instead of extending the internal buffer with this one.

Errors

This function will error

Methods from Deref<Target = Buffer>§

Returns true if and only if this buffer is empty.

Returns the length of this buffer in bytes.

Clears this buffer.

Return the underlying data of the buffer.

Return the underlying data of the buffer as a mutable slice.

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more