Hello,
Could the type StdinLock<'_> provide an access to the buffer like BufReader?
The alternative could be to create a BufReader of io::Stdin and if I want it clonable then I would need to use Rc<RefCell<BufReader<io::Stdin>>>.
Hello,
Could the type StdinLock<'_> provide an access to the buffer like BufReader?
The alternative could be to create a BufReader of io::Stdin and if I want it clonable then I would need to use Rc<RefCell<BufReader<io::Stdin>>>.
What's your end goal? You can use fill_buf to immutably borrow the read-but-not-consumed portion of it.
If the buffer is empty then I try to switch the terminal to raw mode, read a single character else I read the character that's in the buffer.
If I use fill_buf then it will try to fill the buffer which will block.
Sorry, I skipped over that requirement in your subject. Other that double-buffering, you could keep track of how much data is pending yourself (though that seems fragile), or submit a PR to see how the lib team feels about having a buffer method on StdLock like the one on BufReader (the process would take awhile).
Or perhaps termion::async_stdin (or other parts of termion) can serve your needs, if you're working with TTYs.
Thank you.