pub struct Stderr { /* private fields */ }std only.Expand description
๐
std
A handle to the standard error stream of a process.
๐sys/io re-exported from std::io
๐
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ยง
Sourceยงimpl Stderr
impl Stderr
1.0.0 ยท Sourcepub fn lock(&self) -> StderrLock<'static> โ
pub fn lock(&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(())
}Trait Implementationsยง
1.63.0 ยท Sourceยงimpl AsFd for Stderr
impl AsFd for Stderr
Sourceยงfn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.70.0 ยท Sourceยงimpl IsTerminal for Stderr
impl IsTerminal for Stderr
Sourceยงfn is_terminal(&self) -> bool
fn is_terminal(&self) -> bool
true if the descriptor/handle refers to a terminal/tty. Read moreimpl RefUnwindSafe for Stderr
Sourceยงimpl StdioExt for Stderr
impl StdioExt for Stderr
Sourceยงfn set_fd<T>(&mut self, fd: T) -> Result<(), Error> โ
fn set_fd<T>(&mut self, fd: T) -> Result<(), Error> โ
stdio_swap)fd. Read moreSourceยงimpl TextOut for Stderr
Emits UTF-8 text to the process standard error stream.
impl TextOut for Stderr
Emits UTF-8 text to the process standard error stream.
Sourceยงfn write_text(&mut self, text: &str) -> Result<(), Self::Error> โ
fn write_text(&mut self, text: &str) -> Result<(), Self::Error> โ
text without appending a line ending.Sourceยงfn write_line(&mut self, text: &str) -> Result<(), Self::Error> โ
fn write_line(&mut self, text: &str) -> Result<(), Self::Error> โ
text followed by \n.impl UnwindSafe for Stderr
1.0.0 ยท Sourceยงimpl Write for Stderr
impl Write for Stderr
Sourceยงfn write(&mut self, buf: &[u8]) -> Result<usize, Error> โ
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> โ
Sourceยงfn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Sourceยงfn flush(&mut self) -> Result<(), Error> โ
fn flush(&mut self) -> Result<(), Error> โ
Sourceยงfn write_all(&mut self, buf: &[u8]) -> Result<(), Error> โ
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> โ
Sourceยงfn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error> โ
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error> โ
write_all_vectored)1.48.0 ยท Sourceยงimpl Write for &Stderr
impl Write for &Stderr
Sourceยงfn write(&mut self, buf: &[u8]) -> Result<usize, Error> โ
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> โ
Sourceยงfn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Sourceยงfn flush(&mut self) -> Result<(), Error> โ
fn flush(&mut self) -> Result<(), Error> โ
Sourceยงfn write_all(&mut self, buf: &[u8]) -> Result<(), Error> โ
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> โ
Sourceยงfn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error> โ
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error> โ
write_all_vectored)Auto Trait Implementationsยง
impl Freeze for Stderr
impl Send for Stderr
impl Sync for Stderr
impl Unpin for Stderr
impl UnsafeUnpin for Stderr
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.