File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ pub fn stdin() -> Stdin {
4747#[ derive( Debug ) ]
4848pub struct Stdin ( Mutex < State > ) ;
4949
50+ #[ derive( Debug ) ]
51+ pub struct StdinLock < ' a > ( std:: io:: StdinLock < ' a > ) ;
52+
53+ unsafe impl Send for StdinLock < ' _ > { }
54+
5055/// The state of the asynchronous stdin.
5156///
5257/// The stdin can be either idle or busy performing an asynchronous operation.
@@ -157,12 +162,14 @@ impl Stdin {
157162 /// #
158163 /// # Ok(()) }) }
159164 /// ```
160- pub async fn lock ( & self ) -> std :: io :: StdinLock < ' static > {
165+ pub async fn lock ( & self ) -> StdinLock < ' static > {
161166 lazy_static ! {
162167 static ref STDIN : std:: io:: Stdin = std:: io:: stdin( ) ;
163168 }
164169
165- STDIN . lock ( )
170+ blocking:: spawn ( async {
171+ StdinLock ( STDIN . lock ( ) )
172+ } ) . await
166173 }
167174}
168175
@@ -248,3 +255,13 @@ cfg_if! {
248255 }
249256 }
250257}
258+
259+ impl Read for StdinLock < ' _ > {
260+ fn poll_read (
261+ self : Pin < & mut Self > ,
262+ _cx : & mut Context < ' _ > ,
263+ _buf : & mut [ u8 ] ,
264+ ) -> Poll < io:: Result < usize > > {
265+ unimplemented ! ( )
266+ }
267+ }
You can’t perform that action at this time.
0 commit comments