Skip to main content

DisplayBackend

Trait DisplayBackend 

Source
pub trait DisplayBackend: Write {
    // Required methods
    fn set_attributes(&mut self, attributes: Attributes) -> Result<()>;
    fn set_fg(&mut self, color: Color) -> Result<()>;
    fn set_bg(&mut self, color: Color) -> Result<()>;

    // Provided method
    fn write_styled(&mut self, styled: &Styled<dyn Display + '_>) -> Result<()> { ... }
}
Expand description

A trait to represent a terminal that can be rendered to without interaction.

Required Methods§

Source

fn set_attributes(&mut self, attributes: Attributes) -> Result<()>

Sets the given attributes removing ones which were previous applied.

Source

fn set_fg(&mut self, color: Color) -> Result<()>

Sets the foreground color.

Source

fn set_bg(&mut self, color: Color) -> Result<()>

Sets the background color.

Provided Methods§

Source

fn write_styled(&mut self, styled: &Styled<dyn Display + '_>) -> Result<()>

Write a styled object to the backend.

See also Styled and Stylize.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<B: DisplayBackend> DisplayBackend for &mut B

Source§

fn set_attributes(&mut self, attributes: Attributes) -> Result<()>

Source§

fn set_fg(&mut self, color: Color) -> Result<()>

Source§

fn set_bg(&mut self, color: Color) -> Result<()>

Source§

fn write_styled(&mut self, styled: &Styled<dyn Display + '_>) -> Result<()>

Implementors§

Source§

impl DisplayBackend for TestBackend

Source§

impl<W: Write + AsFd> DisplayBackend for TermionBackend<W>

Available on crate feature termion only.
Source§

impl<W: Write> DisplayBackend for CrosstermBackend<W>

Available on crate feature crossterm only.
Source§

impl<W: Write> DisplayBackend for TermionDisplayBackend<W>

Available on crate feature termion only.