Crate anstyle_stream

Source
Expand description

Auto-adapting stdout / stderr streams

AutoStream always accepts ANSI escape codes, adapting to the user’s terminal’s capabilities.

Benefits

  • Allows the caller to not be concerned with the terminal’s capabilities
  • Semver safe way of passing styled text between crates as ANSI escape codes offer more compatibility than most crate APIs.

§Example

use anstyle_stream::println;
use owo_colors::OwoColorize as _;

// Foreground colors
println!("My number is {:#x}!", 10.green());
// Background colors
println!("My number is not {}!", 4.on_red());

And this will correctly handle piping to a file, etc

Modules§

adapter
Gracefully degrade styled output

Macros§

eprintauto
Prints to stderr.
eprintlnauto
Prints to stderr, with a newline.
panicauto
Panics the current thread.
printauto
Prints to stdout.
printlnauto
Prints to stdout, with a newline.

Structs§

AutoStream
std::io::Write that adapts ANSI escape codes to the underlying Writes capabilities
Buffer
In-memory RawStream
StripStream
Only pass printable data to the inner Write

Enums§

ColorChoiceauto
Selection for overriding color output with force_color Selection for overriding color output

Traits§

Lockable
Explicitly lock a std::io::Writeable
RawStream
Required functionality for underlying std::io::Write for adaptation

Functions§

force_colorauto
Override the detected ColorChoice
stderrauto
Create an ANSI escape code compatible stderr
stdoutauto
Create an ANSI escape code compatible stdout