I have a little snippet of code below where I'm asking a user to input a password, and I want to supress the characters they are typing from displaying. (This isn't a high-security app, just a little toy application I'm writing to learn). I would appreciate any suggestions.
fn handle_login(mut stream: TcpStream, command: &str, argument: &str) {
let pwprompt = "Please enter your password: ";
stream.write(pwprompt.as_bytes()).unwrap();
stream.flush().unwrap();
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();
let mut user_password = String::from_utf8_lossy(&mut buffer);
Telnet supports something called IAC commands. You should send the appropriate IAC command and hope that whatever telnet client the user is using supports it. See e.g. this answer for an IAC command you might want to try.