Struct StdinLock
struct StdinLock<'a> { ... }
A locked reference to the Stdin handle.
This handle implements both the Read and BufRead traits, and
is constructed via the Stdin::lock 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 read 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.
Examples
use std::io::{self, BufRead};
fn main() -> io::Result<()> {
let mut buffer = String::new();
let stdin = io::stdin(); // We get `Stdin` here.
{
let mut handle = stdin.lock(); // We get `StdinLock` here.
handle.read_line(&mut buffer)?;
} // `StdinLock` is dropped here.
Ok(())
}
Implementations
impl BufRead for StdinLock<'_>
fn fill_buf(self: &mut Self) -> Result<&[u8]>fn consume(self: &mut Self, n: usize)fn read_until(self: &mut Self, byte: u8, buf: &mut Vec<u8>) -> Result<usize>fn read_line(self: &mut Self, buf: &mut String) -> Result<usize>
impl Debug for StdinLock<'_>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl IsTerminal for StdinLock<'_>
fn is_terminal(self: &Self) -> bool
impl Read for StdinLock<'_>
fn read(self: &mut Self, buf: &mut [u8]) -> Result<usize>fn read_buf(self: &mut Self, buf: BorrowedCursor<'_>) -> Result<()>fn read_vectored(self: &mut Self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>fn is_read_vectored(self: &Self) -> boolfn read_to_end(self: &mut Self, buf: &mut Vec<u8>) -> Result<usize>fn read_to_string(self: &mut Self, buf: &mut String) -> Result<usize>fn read_exact(self: &mut Self, buf: &mut [u8]) -> Result<()>fn read_buf_exact(self: &mut Self, cursor: BorrowedCursor<'_>) -> Result<()>
impl StdioExt for StdinLock<'_>
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<'a> AsFd for StdinLock<'a>
fn as_fd(self: &Self) -> BorrowedFd<'_>
impl<'a> AsHandle for StdinLock<'a>
fn as_handle(self: &Self) -> BorrowedHandle<'_>
impl<'a> AsRawFd for StdinLock<'a>
fn as_raw_fd(self: &Self) -> RawFd
impl<'a> AsRawHandle for StdinLock<'a>
fn as_raw_handle(self: &Self) -> RawHandle
impl<'a> Freeze for StdinLock<'a>
impl<'a> RefUnwindSafe for StdinLock<'a>
impl<'a> Send for StdinLock<'a>
impl<'a> Sync for StdinLock<'a>
impl<'a> Unpin for StdinLock<'a>
impl<'a> UnsafeUnpin for StdinLock<'a>
impl<'a> UnwindSafe for StdinLock<'a>
impl<T> Any for StdinLock<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for StdinLock<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for StdinLock<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for StdinLock<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for StdinLock<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for StdinLock<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for StdinLock<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>