Expand description
Auto-adapting stdout
/ stderr
streams
A portmanteau of “ansi stream”
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.
Available styling crates:
- anstyle for minimal runtime styling, designed to go in public APIs
- owo-colors for feature-rich runtime styling
- color-print for feature-rich compile-time styling
§Example
use anstream::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
Re-exports§
pub use buffer::Buffer;
Deprecated
Modules§
- Gracefully degrade styled output
- Higher-level traits to describe writeable streams
Macros§
- eprint
auto
Prints tostderr
. - eprintln
auto
Prints tostderr
, with a newline. - panic
auto
Panics the current thread. - print
auto
Prints tostdout
. - println
auto
Prints tostdout
, with a newline.
Structs§
std::io::Write
that adapts ANSI escape codes to the underlyingWrite
s capabilities- Only pass printable data to the inner
Write
- Wincon
Stream Windows and wincon
Only pass printable data to the innerWrite
Enums§
- Selection for overriding color output Selection for overriding color output
Functions§
- stderr
auto
Create an ANSI escape code compatible stderr - stdout
auto
Create an ANSI escape code compatible stdout
Type Aliases§
- An adaptive wrapper around the global standard error stream of the current process
- An adaptive wrapper around the global standard output stream of the current process