Struct Stdout

Source
pub struct Stdout(/* private fields */);
Expand description

A handle to the standard output of the current process.

This writer is created by the stdout function. See its documentation for more.

§Note: Windows Portability Consideration

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.

Implementations§

Source§

impl Stdout

Source

pub async fn lock(&self) -> StdoutLock<'static>

Available on unstable only.

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 async_std::io;
use async_std::prelude::*;

let stdout = io::stdout();
let mut handle = stdout.lock().await;

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

Trait Implementations§

Source§

impl AsRawFd for Stdout

Available on Unix only.
Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl AsRawHandle for Stdout

Available on Windows only.
Source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle, without taking any ownership.
Source§

impl Debug for Stdout

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Write for Stdout

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object.
Source§

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to flush the object, ensuring that any buffered data reach their destination.
Source§

fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to close the object.
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize>>

Attempt to write bytes from bufs into the object using vectored IO operations.
Source§

fn write<'a>(&'a mut self, buf: &'a [u8]) -> ImplFuture<Result<usize>>
where Self: Unpin,

Writes some bytes into the byte stream. Read more
Source§

fn flush(&mut self) -> ImplFuture<Result<()>>
where Self: Unpin,

Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§

fn write_vectored<'a>( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> ImplFuture<Result<usize>>
where Self: Unpin,

Like write, except that it writes from a slice of buffers. Read more
Source§

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> ImplFuture<Result<()>>
where Self: Unpin,

Writes an entire buffer into the byte stream. Read more
Source§

fn write_fmt<'a>(&'a mut self, fmt: Arguments<'_>) -> ImplFuture<Result<()>>
where Self: Unpin,

Writes a formatted string into this writer, returning any error encountered. Read more

Auto Trait Implementations§

§

impl !Freeze for Stdout

§

impl RefUnwindSafe for Stdout

§

impl Send for Stdout

§

impl Sync for Stdout

§

impl Unpin for Stdout

§

impl UnwindSafe for Stdout

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> WriteExt for T
where T: Write + ?Sized,

Source§

fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>
where Self: Unpin,

Writes some bytes into the byte stream. Read more
Source§

fn flush(&mut self) -> FlushFuture<'_, Self>
where Self: Unpin,

Flushes the stream to ensure that all buffered contents reach their destination. Read more
Source§

fn write_vectored<'a>( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> WriteVectoredFuture<'a, Self>
where Self: Unpin,

Like write, except that it writes from a slice of buffers. Read more
Source§

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>
where Self: Unpin,

Writes an entire buffer into the byte stream. Read more
Source§

fn write_fmt<'a>(&'a mut self, fmt: Arguments<'_>) -> WriteFmtFuture<'a, Self>
where Self: Unpin,

Writes a formatted string into this writer, returning any error encountered. Read more