Crate rustix_is_terminal
source ·Expand description
rustix-is-terminal is a simple utility that answers one question:
Is this a terminal?
A “terminal”, also known as a “tty”, is an I/O device which may be interactive and may support color and other special features. This crate doesn’t provide any of those features; it just answers this one question.
On Unix-family platforms, this is effectively the same as the isatty
function for testing whether a given stream is a terminal, though it
accepts high-level stream types instead of raw file descriptors.
On Windows, it uses a variety of techniques to determine whether the given stream is a terminal.
§Example
use rustix_is_terminal::IsTerminal;
if std::io::stdout().is_terminal() {
println!("stdout is a terminal")
}
Traits§
- Extension trait to check whether something is a terminal.
Functions§
- Returns
true
ifthis
is a terminal.