From 76b90acb735d3ed2b3052abc1d2403287af83619 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sat, 17 Jun 2017 22:31:27 -0400 Subject: rustfmt: Reformatted all the code. --- src/bin/crypto.rs | 4 +--- src/bin/main.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src/bin') diff --git a/src/bin/crypto.rs b/src/bin/crypto.rs index 5cc8549..775ea07 100644 --- a/src/bin/crypto.rs +++ b/src/bin/crypto.rs @@ -6,9 +6,7 @@ use crypto::bcrypt_pbkdf::bcrypt_pbkdf; pub fn encode(pw: &str) -> Vec { let salt = "hello"; let mut out = vec!(0; 32); - let encrypted = bcrypt_pbkdf( - pw.as_bytes(), salt.as_bytes(), - 10, &mut out); + let encrypted = bcrypt_pbkdf(pw.as_bytes(), salt.as_bytes(), 10, &mut out); out } diff --git a/src/bin/main.rs b/src/bin/main.rs index ed9e179..245416c 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -21,12 +21,11 @@ fn create_user_prompt() -> Option<(String, String)> { let mut user = String::new(); io::stdin().read_line(&mut user).unwrap(); let password = rpassword::prompt_password_stdout("Password: ").unwrap(); - let confirmation = - rpassword::prompt_password_stdout("Repeat password: ").unwrap(); + let confirmation = rpassword::prompt_password_stdout("Repeat password: ").unwrap(); if password != confirmation { error!("Passwords don't match"); - return None + return None; } Some((user.trim().to_string(), password)) } @@ -35,9 +34,7 @@ fn create_admin_user(conn: &rusqlite::Connection) { info!("Create admin user"); if let Some((user, password)) = create_user_prompt() { let enc = auth::encode("test_salt", password.as_str()); - systemhttp::db::insert_user( - &conn, user.as_str(), - &enc).expect("create user"); + systemhttp::db::insert_user(&conn, user.as_str(), &enc).expect("create user"); } } @@ -67,8 +64,11 @@ fn main() { .about("Add an admin user to the db")) .get_matches(); - let port = matches.value_of("port").unwrap_or("8080") - .parse::().expect("port number"); + let port = matches + .value_of("port") + .unwrap_or("8080") + .parse::() + .expect("port number"); let db_file = matches.value_of("db_file").unwrap(); @@ -79,12 +79,12 @@ fn main() { let mut context = systemhttp::server::Context { base_url: "http://localhost:8080".to_string(), - conn: conn + conn: conn, }; match matches.subcommand_name() { Some("serve") => serve(context, port), Some("create_admin_user") => create_admin_user(&context.conn), - x => panic!("Don't know about subcommand: {:?}", x) + x => panic!("Don't know about subcommand: {:?}", x), } } -- cgit v1.2.3