Struct Stderr

struct Stderr { ... }

A handle to the standard error stream of a process.

For more information, see the io::stderr method.

Note: Windows Portability Considerations

When operating in a console, the Windows implementation of this stream does not support non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return an error.

In a process with a detached console, such as one using #![windows_subsystem = "windows"], or in a child process spawned from such a process, the contained handle will be null. In such cases, the standard library's Read and Write will do nothing and silently succeed. All other I/O operations, via the standard library or via raw Windows API calls, will fail.

Implementations

impl Stderr

fn lock(self: &Self) -> StderrLock<'static>

Locks this handle to the standard error stream, returning a writable guard.

The lock is released when the returned lock goes out of scope. The returned guard also implements the Write trait for writing data.

Examples

use std::io::{self, Write};

fn foo() -> io::Result<()> {
    let stderr = io::stderr();
    let mut handle = stderr.lock();

    handle.write_all(b"hello world")?;

    Ok(())
}

impl AsFd for Stderr

fn as_fd(self: &Self) -> BorrowedFd<'_>

impl AsHandle for Stderr

fn as_handle(self: &Self) -> BorrowedHandle<'_>

impl AsRawFd for Stderr

fn as_raw_fd(self: &Self) -> RawFd

impl AsRawHandle for Stderr

fn as_raw_handle(self: &Self) -> RawHandle

impl Debug for Stderr

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Freeze for Stderr

impl IsTerminal for Stderr

fn is_terminal(self: &Self) -> bool

impl RefUnwindSafe for Stderr

impl Send for Stderr

impl StdioExt for Stderr

fn set_fd<T: Into<OwnedFd>>(self: &mut Self, fd: T) -> Result<()>
fn take_fd(self: &mut Self) -> Result<OwnedFd>
fn replace_fd<T: Into<OwnedFd>>(self: &mut Self, replace_with: T) -> Result<OwnedFd>

impl Sync for Stderr

impl Unpin for Stderr

impl UnsafeUnpin for Stderr

impl UnwindSafe for Stderr

impl Write for Stderr

fn write(self: &mut Self, buf: &[u8]) -> Result<usize>
fn write_vectored(self: &mut Self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn is_write_vectored(self: &Self) -> bool
fn flush(self: &mut Self) -> Result<()>
fn write_all(self: &mut Self, buf: &[u8]) -> Result<()>
fn write_all_vectored(self: &mut Self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_fmt(self: &mut Self, args: Arguments<'_>) -> Result<()>

impl<T> Any for Stderr

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Stderr

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Stderr

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Stderr

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Stderr

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Stderr

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Stderr

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>