Trait std::io::IsTerminal

1.70.0 · source ·
pub trait IsTerminal: Sealed {
    // Required method
    fn is_terminal(&self) -> bool;
}
Expand description

Trait to determine if a descriptor/handle refers to a terminal/tty.

Required Methods§

1.70.0 · source

fn is_terminal(&self) -> bool

Returns true if the descriptor/handle refers to a terminal/tty.

On platforms where Rust does not know how to detect a terminal yet, this will return false. This will also return false if an unexpected error occurred, such as from passing an invalid file descriptor.

§Platform-specific behavior

On Windows, in addition to detecting consoles, this currently uses some heuristics to detect older msys/cygwin/mingw pseudo-terminals based on device name: devices with names starting with msys- or cygwin- and ending in -pty will be considered terminals. Note that this may change in the future.

Implementors§

1.70.0 · source§

impl IsTerminal for File

1.70.0 · source§

impl IsTerminal for BorrowedFd<'_>

1.70.0 · source§

impl IsTerminal for OwnedFd

1.70.0 · source§

impl IsTerminal for BorrowedHandle<'_>

Available on Windows only.
1.70.0 · source§

impl IsTerminal for OwnedHandle

Available on Windows only.
1.70.0 · source§

impl IsTerminal for Stderr

1.70.0 · source§

impl IsTerminal for StderrLock<'_>

1.70.0 · source§

impl IsTerminal for Stdin

1.70.0 · source§

impl IsTerminal for StdinLock<'_>

1.70.0 · source§

impl IsTerminal for Stdout

1.70.0 · source§

impl IsTerminal for StdoutLock<'_>