From e7a5fcf01b4e2b77f26d81d9236731d3b02b6d16 Mon Sep 17 00:00:00 2001 From: Antoine Gersant Date: Sun, 28 Oct 2018 10:53:44 -0700 Subject: [PATCH] Autoformat --- src/api.rs | 2 +- src/index.rs | 8 ++++--- src/rocket_api.rs | 54 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/api.rs b/src/api.rs index 452c673..50450e2 100644 --- a/src/api.rs +++ b/src/api.rs @@ -15,7 +15,7 @@ use std::fs; use std::io; use std::ops::Deref; use std::path::*; -use std::sync::{Arc}; +use std::sync::Arc; use typemap; use url::percent_encoding::percent_decode; diff --git a/src/index.rs b/src/index.rs index cefc852..8e69680 100644 --- a/src/index.rs +++ b/src/index.rs @@ -17,8 +17,8 @@ use std::time; use config::MiscSettings; #[cfg(test)] use db; -use db::{ConnectionSource, DB}; use db::{directories, misc_settings, songs}; +use db::{ConnectionSource, DB}; use errors; use metadata; use vfs::{VFSSource, VFS}; @@ -42,7 +42,7 @@ struct CommandReceiver { impl CommandReceiver { fn new(receiver: Receiver) -> CommandReceiver { - CommandReceiver{ receiver } + CommandReceiver { receiver } } } @@ -52,7 +52,9 @@ pub struct CommandSender { impl CommandSender { fn new(sender: Sender) -> CommandSender { - CommandSender{ sender: Mutex::new(sender) } + CommandSender { + sender: Mutex::new(sender), + } } pub fn trigger_reindex(&self) -> Result<(), errors::Error> { diff --git a/src/rocket_api.rs b/src/rocket_api.rs index 222ea38..5aba579 100644 --- a/src/rocket_api.rs +++ b/src/rocket_api.rs @@ -16,7 +16,18 @@ const CURRENT_MINOR_VERSION: i32 = 2; const SESSION_FIELD_USERNAME: &str = "username"; pub fn get_routes() -> Vec { - routes![version, initial_setup, get_settings, put_settings, trigger_index, auth, browse_root, browse, flatten_root, flatten] + routes![ + version, + initial_setup, + get_settings, + put_settings, + trigger_index, + auth, + browse_root, + browse, + flatten_root, + flatten + ] } struct Auth { @@ -96,13 +107,20 @@ fn get_settings(db: State, _admin_rights: AdminRights) -> Result, _admin_rights: AdminRights, config: Json) -> Result<(), errors::Error> { +fn put_settings( + db: State, + _admin_rights: AdminRights, + config: Json, +) -> Result<(), errors::Error> { config::amend::(&db, &config)?; Ok(()) } #[post("/trigger_index")] -fn trigger_index(command_sender: State>, _admin_rights: AdminRights) -> Result<(), errors::Error> { +fn trigger_index( + command_sender: State>, + _admin_rights: AdminRights, +) -> Result<(), errors::Error> { command_sender.trigger_reindex()?; Ok(()) } @@ -119,9 +137,16 @@ struct AuthOutput { } #[post("/auth", data = "")] -fn auth(db: State, credentials: Json, mut cookies: Cookies) -> Result<(Json), errors::Error> { +fn auth( + db: State, + credentials: Json, + mut cookies: Cookies, +) -> Result<(Json), errors::Error> { user::auth::(&db, &credentials.username, &credentials.password)?; - cookies.add_private(Cookie::new(SESSION_FIELD_USERNAME, credentials.username.clone())); + cookies.add_private(Cookie::new( + SESSION_FIELD_USERNAME, + credentials.username.clone(), + )); let auth_output = AuthOutput { admin: user::is_admin::(&db, &credentials.username)?, @@ -130,13 +155,20 @@ fn auth(db: State, credentials: Json, mut cookies: Cookies) } #[get("/browse")] -fn browse_root(db: State, _auth: Auth) -> Result<(Json>), errors::Error> { +fn browse_root( + db: State, + _auth: Auth, +) -> Result<(Json>), errors::Error> { let result = index::browse::(&db, &PathBuf::new())?; Ok(Json(result)) } #[get("/browse/")] -fn browse(db: State, _auth: Auth, path: PathBuf) -> Result<(Json>), errors::Error> { +fn browse( + db: State, + _auth: Auth, + path: PathBuf, +) -> Result<(Json>), errors::Error> { let result = index::browse::(&db, &path)?; Ok(Json(result)) } @@ -148,7 +180,11 @@ fn flatten_root(db: State, _auth: Auth) -> Result<(Json>), } #[get("/flatten/")] -fn flatten(db: State, _auth: Auth, path: PathBuf) -> Result<(Json>), errors::Error> { +fn flatten( + db: State, + _auth: Auth, + path: PathBuf, +) -> Result<(Json>), errors::Error> { let result = index::flatten::(&db, &path)?; Ok(Json(result)) -} \ No newline at end of file +}