pub struct Stdout {
inner: &'static ReentrantLock<RefCell<LineWriter<StdoutRaw>>>,
}Expand description
A handle to the global standard output stream of the current process.
Each handle shares a global buffer of data to be written to the standard
output stream. Access is also synchronized via a lock and explicit control
over locking is available via the lock method.
By default, the handle is line-buffered when connected to a terminal, meaning
it flushes automatically when a newline (\n) is encountered. For immediate
output, you can manually call the flush method. When the handle goes out
of scope, the buffer is automatically flushed.
Created by the io::stdout 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.
Fields§
§inner: &'static ReentrantLock<RefCell<LineWriter<StdoutRaw>>>Implementations§
Trait Implementations§
1.63.0 · Source§impl AsFd for Stdout
Available on Unix or Hermit or Trusty or WASI or Motor OS only.
impl AsFd for Stdout
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
1.21.0 · Source§impl AsRawFd for Stdout
Available on Unix or Hermit or Trusty or WASI or Motor OS only.
impl AsRawFd for Stdout
1.70.0 · Source§impl IsTerminal for Stdout
impl IsTerminal for Stdout
Source§fn is_terminal(&self) -> bool
fn is_terminal(&self) -> bool
true if the descriptor/handle refers to a terminal/tty. Read moreSource§impl StdioExt for Stdout
Available on non-Hermit and (Unix) and not ((WebAssembly and non-WASI, or Fortanix and SGX)) only.
impl StdioExt for Stdout
Source§fn set_fd<T: Into<OwnedFd>>(&mut self, fd: T) -> Result<()>
fn set_fd<T: Into<OwnedFd>>(&mut self, fd: T) -> Result<()>
stdio_swap #150667)fd. Read more1.48.0 · Source§impl Write for &Stdout
impl Write for &Stdout
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector #69941)Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored #70436)1.0.0 · Source§impl Write for Stdout
impl Write for Stdout
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector #69941)Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored #70436)impl RefUnwindSafe for Stdout
impl Sealed for Stdout
impl UnwindSafe for Stdout
Auto Trait Implementations§
impl Freeze for Stdout
impl Send for Stdout
impl Sync for Stdout
impl Unpin for Stdout
impl UnsafeUnpin for Stdout
Blanket Implementations§
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> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type #102070)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more