Skip to main content

ReadoutBuf

Trait ReadoutBuf 

Source
pub trait ReadoutBuf {
    // Required method
    fn write_str(&mut self, s: &str) -> Result;

    // Provided method
    fn reserve(&mut self, _additional: usize) { ... }
}
Expand description

Append-only write surface a readout writes its rendered piece into. Implementations decide how to handle styling (ANSI inline vs. typed style runs) and ANSI stripping (TTY vs. non-TTY sinks).

The trait is intentionally minimal — write_str is enough for the Push 1 built-in. Later pushes will extend it with style-run pushes (push_styled) once the colour / style sub-language lands; until then, readouts emit ANSI escapes as part of write_str payloads when they want styling, and the buffer’s own ANSI policy decides whether to keep or strip.

Required Methods§

Source

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

Append the given UTF-8 text. Must not allocate independently of the underlying storage’s growth.

Provided Methods§

Source

fn reserve(&mut self, _additional: usize)

Hint about how many more bytes will be appended. Implementations may use this to reserve capacity. Optional — default no-op.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§