localauth 0.1.5

A simple local variable based authentication crate. NO encryption or data persistence yet
Documentation
// Imports
use rpassword::read_password;
use std::io::{Write, stdin, stdout};

// User struct
pub struct User {
    pub username: String,
    pub password: String,
}

impl User {
    // New blank account
    pub fn new() -> Self {
        Self {
            username: String::new(),
            password: String::new(),
        }
    }

    // New account with set credentials
    pub fn from(username: &str, password: &str) -> Self {
        Self {
            username: String::from(username),
            password: String::from(password),
        }
    }

    // Register user account
    pub fn register() -> Self {
        // New account credentials
        let mut new_username = String::new();
        let mut new_password = String::new();

        // New username input
        print!("New username: ");
        stdout().flush().unwrap();
        stdin()
            .read_line(&mut new_username)
            .expect("Invalid username input!");
        let new_username = new_username.trim();

        // New password input
        print!("New password (all spaces are removed): ");
        stdout().flush().unwrap();
        new_password = read_password()
            .expect("Invalid password input!")
            .replace(" ", "");
        let new_password = new_password.trim();

        // Return registered user
        Self::from(new_username, new_password)
    }

    // Register user account
    pub fn verify(&self) -> bool {
        let mut password = String::new();

        // Password input
        print!("Password: ");
        stdout().flush().unwrap();
        password = read_password()
            .expect("Invalid password input!");
        let password = password.trim();

        if password == self.password{
            true
        } else { 
            false
        }
    }
}