Skip to main content

DebugWriter

Trait DebugWriter 

Source
pub trait DebugWriter {
    // Required methods
    fn write(&self, bytes: &[u8], overflow_message: &[u8]) -> usize;
    fn available_len(&self) -> usize;
    fn to_write_len(&self) -> usize;
    fn publish(&self) -> usize;
    fn flush(&self, writer: &mut dyn IoWrite);
}
Expand description

A trait for writing debug output.

This can be used for example to implement asynchronous or synchronous writers, and buffered or unbuffered writers. Various platforms may have in-memory logs, memory mapped “endless” FIFOs, JTAG support for output, etc.

Required Methods§

Source

fn write(&self, bytes: &[u8], overflow_message: &[u8]) -> usize

Write bytes to output with overflow notification.

The overflow slice is used as a message to be appended to the end of the available buffer if it becomes full.

Source

fn available_len(&self) -> usize

Available length of the internal buffer if limited.

If the buffer can support a write of any size, it should lie and return usize::MAX.

Across subsequent calls to this function, without invoking write() in between, this returned value may only increase, but never decrease.

Source

fn to_write_len(&self) -> usize

How many bytes are buffered and not yet written.

Source

fn publish(&self) -> usize

Publish bytes from the internal buffer to the output.

Returns how many bytes were written.

Source

fn flush(&self, writer: &mut dyn IoWrite)

Flush any buffered bytes to the provided output writer.

flush() should be used to write any buffered bytes to a new writer instead of the internal writer that publish() would use.

Trait Implementations§

Source§

impl Write for &dyn DebugWriter

Source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§