Skip to content
Snippets Groups Projects
Commit b10a24e1 authored by Ticki's avatar Ticki
Browse files

Remove 'into_async', use 'async_stdin' instead

parent 7d1d424c
No related branches found
No related tags found
No related merge requests found
use std::io::{self, Read, Write};
use std::thread;
use std::sync::mpsc;
use {IntoRawMode, AsyncReader};
use IntoRawMode;
#[cfg(feature = "nightly")]
use std::io::{Chars, CharsError};
......@@ -87,11 +85,6 @@ pub trait TermRead {
/// EOT and ETX will abort the prompt, returning `None`. Newline or carriage return will
/// complete the password input.
fn read_passwd<W: Write>(&mut self, writer: &mut W) -> io::Result<Option<String>>;
/// Turn the reader into a asynchronous reader.
///
/// This will spawn up another thread listening for event, buffering them in a mpsc queue.
fn into_async(self) -> AsyncReader where Self: Send;
}
impl<R: Read> TermRead for R {
......@@ -119,28 +112,6 @@ impl<R: Read> TermRead for R {
Ok(Some(passwd))
}
fn into_async(self) -> AsyncReader where R: Send + 'static {
let (send, recv) = mpsc::channel();
thread::spawn(move || {
let mut reader = self;
loop {
let mut buf = [0];
if send.send(if let Err(k) = reader.read(&mut buf) {
Err(k)
} else {
Ok(buf[0])
}).is_err() {
return;
};
}
});
AsyncReader {
recv: recv,
}
}
}
#[cfg(test)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment