mirror of
				https://github.com/async-rs/async-std.git
				synced 2025-10-25 05:46:43 +00:00 
			
		
		
		
	
							parent
							
								
									0ec027dbff
								
							
						
					
					
						commit
						721760a7a6
					
				
					 4 changed files with 0 additions and 210 deletions
				
			
		|  | @ -328,12 +328,3 @@ cfg_default! { | ||||||
|     #[cfg(not(target_os = "unknown"))] |     #[cfg(not(target_os = "unknown"))] | ||||||
|     mod stdout; |     mod stdout; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| cfg_unstable_default! { |  | ||||||
|     #[cfg(not(target_os = "unknown"))] |  | ||||||
|     pub use stderr::StderrLock; |  | ||||||
|     #[cfg(not(target_os = "unknown"))] |  | ||||||
|     pub use stdin::StdinLock; |  | ||||||
|     #[cfg(not(target_os = "unknown"))] |  | ||||||
|     pub use stdout::StdoutLock; |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -5,11 +5,6 @@ use std::future::Future; | ||||||
| use crate::io::{self, Write}; | use crate::io::{self, Write}; | ||||||
| use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | ||||||
| 
 | 
 | ||||||
| cfg_unstable! { |  | ||||||
|     use once_cell::sync::Lazy; |  | ||||||
|     use std::io::Write as _; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// Constructs a new handle to the standard error of the current process.
 | /// Constructs a new handle to the standard error of the current process.
 | ||||||
| ///
 | ///
 | ||||||
| /// This function is an async version of [`std::io::stderr`].
 | /// This function is an async version of [`std::io::stderr`].
 | ||||||
|  | @ -58,22 +53,6 @@ pub fn stderr() -> Stderr { | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub struct Stderr(Mutex<State>); | pub struct Stderr(Mutex<State>); | ||||||
| 
 | 
 | ||||||
| /// A locked reference to the Stderr handle.
 |  | ||||||
| ///
 |  | ||||||
| /// This handle implements the [`Write`] traits, and is constructed via the [`Stderr::lock`]
 |  | ||||||
| /// method.
 |  | ||||||
| ///
 |  | ||||||
| /// [`Write`]: trait.Read.html
 |  | ||||||
| /// [`Stderr::lock`]: struct.Stderr.html#method.lock
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| #[derive(Debug)] |  | ||||||
| pub struct StderrLock<'a>(std::io::StderrLock<'a>); |  | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| unsafe impl Send for StderrLock<'_> {} |  | ||||||
| 
 |  | ||||||
| /// The state of the asynchronous stderr.
 | /// The state of the asynchronous stderr.
 | ||||||
| ///
 | ///
 | ||||||
| /// The stderr can be either idle or busy performing an asynchronous operation.
 | /// The stderr can be either idle or busy performing an asynchronous operation.
 | ||||||
|  | @ -108,35 +87,6 @@ enum Operation { | ||||||
|     Flush(io::Result<()>), |     Flush(io::Result<()>), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Stderr { |  | ||||||
|     /// 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
 |  | ||||||
|     ///
 |  | ||||||
|     /// ```no_run
 |  | ||||||
|     /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
 |  | ||||||
|     /// #
 |  | ||||||
|     /// use async_std::io;
 |  | ||||||
|     /// use async_std::prelude::*;
 |  | ||||||
|     ///
 |  | ||||||
|     /// let stderr = io::stderr();
 |  | ||||||
|     /// let mut handle = stderr.lock().await;
 |  | ||||||
|     ///
 |  | ||||||
|     /// handle.write_all(b"hello world").await?;
 |  | ||||||
|     /// #
 |  | ||||||
|     /// # Ok(()) }) }
 |  | ||||||
|     /// ```
 |  | ||||||
|     #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
|     #[cfg(any(feature = "unstable", feature = "docs"))] |  | ||||||
|     pub async fn lock(&self) -> StderrLock<'static> { |  | ||||||
|         static STDERR: Lazy<std::io::Stderr> = Lazy::new(std::io::stderr); |  | ||||||
| 
 |  | ||||||
|         spawn_blocking(move || StderrLock(STDERR.lock())).await |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl Write for Stderr { | impl Write for Stderr { | ||||||
|     fn poll_write( |     fn poll_write( | ||||||
|         mut self: Pin<&mut Self>, |         mut self: Pin<&mut Self>, | ||||||
|  | @ -239,23 +189,3 @@ cfg_windows! { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| impl io::Write for StderrLock<'_> { |  | ||||||
|     fn poll_write( |  | ||||||
|         mut self: Pin<&mut Self>, |  | ||||||
|         _cx: &mut Context<'_>, |  | ||||||
|         buf: &[u8], |  | ||||||
|     ) -> Poll<io::Result<usize>> { |  | ||||||
|         Poll::Ready(self.0.write(buf)) |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     fn poll_flush(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> { |  | ||||||
|         Poll::Ready(self.0.flush()) |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { |  | ||||||
|         self.poll_flush(cx) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -7,11 +7,6 @@ use crate::io::{self, Read}; | ||||||
| use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | ||||||
| use crate::utils::Context as _; | use crate::utils::Context as _; | ||||||
| 
 | 
 | ||||||
| cfg_unstable! { |  | ||||||
|     use once_cell::sync::Lazy; |  | ||||||
|     use std::io::Read as _; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// Constructs a new handle to the standard input of the current process.
 | /// Constructs a new handle to the standard input of the current process.
 | ||||||
| ///
 | ///
 | ||||||
| /// This function is an async version of [`std::io::stdin`].
 | /// This function is an async version of [`std::io::stdin`].
 | ||||||
|  | @ -61,21 +56,6 @@ pub fn stdin() -> Stdin { | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub struct Stdin(Mutex<State>); | pub struct Stdin(Mutex<State>); | ||||||
| 
 | 
 | ||||||
| /// A locked reference to the Stdin handle.
 |  | ||||||
| ///
 |  | ||||||
| /// This handle implements the [`Read`] traits, and is constructed via the [`Stdin::lock`] method.
 |  | ||||||
| ///
 |  | ||||||
| /// [`Read`]: trait.Read.html
 |  | ||||||
| /// [`Stdin::lock`]: struct.Stdin.html#method.lock
 |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[derive(Debug)] |  | ||||||
| pub struct StdinLock<'a>(std::io::StdinLock<'a>); |  | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| unsafe impl Send for StdinLock<'_> {} |  | ||||||
| 
 |  | ||||||
| /// The state of the asynchronous stdin.
 | /// The state of the asynchronous stdin.
 | ||||||
| ///
 | ///
 | ||||||
| /// The stdin can be either idle or busy performing an asynchronous operation.
 | /// The stdin can be either idle or busy performing an asynchronous operation.
 | ||||||
|  | @ -165,35 +145,6 @@ impl Stdin { | ||||||
|         .await |         .await | ||||||
|         .context(|| String::from("could not read line on stdin")) |         .context(|| String::from("could not read line on stdin")) | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     /// Locks this handle to the standard input stream, returning a readable guard.
 |  | ||||||
|     ///
 |  | ||||||
|     /// The lock is released when the returned lock goes out of scope. The returned guard also implements the Read trait for accessing the underlying data.
 |  | ||||||
|     ///
 |  | ||||||
|     /// # Examples
 |  | ||||||
|     ///
 |  | ||||||
|     /// ```no_run
 |  | ||||||
|     /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
 |  | ||||||
|     /// #
 |  | ||||||
|     /// use async_std::io;
 |  | ||||||
|     /// use async_std::prelude::*;
 |  | ||||||
|     ///
 |  | ||||||
|     /// let mut buffer = String::new();
 |  | ||||||
|     ///
 |  | ||||||
|     /// let stdin = io::stdin();
 |  | ||||||
|     /// let mut handle = stdin.lock().await;
 |  | ||||||
|     ///
 |  | ||||||
|     /// handle.read_to_string(&mut buffer).await?;
 |  | ||||||
|     /// #
 |  | ||||||
|     /// # Ok(()) }) }
 |  | ||||||
|     /// ```
 |  | ||||||
|     #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
|     #[cfg(any(feature = "unstable", feature = "docs"))] |  | ||||||
|     pub async fn lock(&self) -> StdinLock<'static> { |  | ||||||
|         static STDIN: Lazy<std::io::Stdin> = Lazy::new(std::io::stdin); |  | ||||||
| 
 |  | ||||||
|         spawn_blocking(move || StdinLock(STDIN.lock())).await |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Read for Stdin { | impl Read for Stdin { | ||||||
|  | @ -265,15 +216,3 @@ cfg_windows! { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| impl Read for StdinLock<'_> { |  | ||||||
|     fn poll_read( |  | ||||||
|         mut self: Pin<&mut Self>, |  | ||||||
|         _cx: &mut Context<'_>, |  | ||||||
|         buf: &mut [u8], |  | ||||||
|     ) -> Poll<io::Result<usize>> { |  | ||||||
|         Poll::Ready(self.0.read(buf)) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -5,11 +5,6 @@ use std::future::Future; | ||||||
| use crate::io::{self, Write}; | use crate::io::{self, Write}; | ||||||
| use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | use crate::task::{spawn_blocking, Context, JoinHandle, Poll}; | ||||||
| 
 | 
 | ||||||
| cfg_unstable! { |  | ||||||
|     use once_cell::sync::Lazy; |  | ||||||
|     use std::io::Write as _; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /// Constructs a new handle to the standard output of the current process.
 | /// Constructs a new handle to the standard output of the current process.
 | ||||||
| ///
 | ///
 | ||||||
| /// This function is an async version of [`std::io::stdout`].
 | /// This function is an async version of [`std::io::stdout`].
 | ||||||
|  | @ -58,22 +53,6 @@ pub fn stdout() -> Stdout { | ||||||
| #[derive(Debug)] | #[derive(Debug)] | ||||||
| pub struct Stdout(Mutex<State>); | pub struct Stdout(Mutex<State>); | ||||||
| 
 | 
 | ||||||
| /// A locked reference to the Stderr handle.
 |  | ||||||
| ///
 |  | ||||||
| /// This handle implements the [`Write`] traits, and is constructed via the [`Stdout::lock`]
 |  | ||||||
| /// method.
 |  | ||||||
| ///
 |  | ||||||
| /// [`Write`]: trait.Read.html
 |  | ||||||
| /// [`Stdout::lock`]: struct.Stdout.html#method.lock
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| #[derive(Debug)] |  | ||||||
| pub struct StdoutLock<'a>(std::io::StdoutLock<'a>); |  | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| unsafe impl Send for StdoutLock<'_> {} |  | ||||||
| 
 |  | ||||||
| /// The state of the asynchronous stdout.
 | /// The state of the asynchronous stdout.
 | ||||||
| ///
 | ///
 | ||||||
| /// The stdout can be either idle or busy performing an asynchronous operation.
 | /// The stdout can be either idle or busy performing an asynchronous operation.
 | ||||||
|  | @ -108,35 +87,6 @@ enum Operation { | ||||||
|     Flush(io::Result<()>), |     Flush(io::Result<()>), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Stdout { |  | ||||||
|     /// 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
 |  | ||||||
|     ///
 |  | ||||||
|     /// ```no_run
 |  | ||||||
|     /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
 |  | ||||||
|     /// #
 |  | ||||||
|     /// 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?;
 |  | ||||||
|     /// #
 |  | ||||||
|     /// # Ok(()) }) }
 |  | ||||||
|     /// ```
 |  | ||||||
|     #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
|     #[cfg(any(feature = "unstable", feature = "docs"))] |  | ||||||
|     pub async fn lock(&self) -> StdoutLock<'static> { |  | ||||||
|         static STDOUT: Lazy<std::io::Stdout> = Lazy::new(std::io::stdout); |  | ||||||
| 
 |  | ||||||
|         spawn_blocking(move || StdoutLock(STDOUT.lock())).await |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl Write for Stdout { | impl Write for Stdout { | ||||||
|     fn poll_write( |     fn poll_write( | ||||||
|         mut self: Pin<&mut Self>, |         mut self: Pin<&mut Self>, | ||||||
|  | @ -239,23 +189,3 @@ cfg_windows! { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 |  | ||||||
| #[cfg(feature = "unstable")] |  | ||||||
| #[cfg_attr(feature = "docs", doc(cfg(unstable)))] |  | ||||||
| impl Write for StdoutLock<'_> { |  | ||||||
|     fn poll_write( |  | ||||||
|         mut self: Pin<&mut Self>, |  | ||||||
|         _cx: &mut Context<'_>, |  | ||||||
|         buf: &[u8], |  | ||||||
|     ) -> Poll<io::Result<usize>> { |  | ||||||
|         Poll::Ready(self.0.write(buf)) |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     fn poll_flush(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> { |  | ||||||
|         Poll::Ready(self.0.flush()) |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { |  | ||||||
|         self.poll_flush(cx) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue