From 3f735f7f5634e93e71c0f9602d58ae60311578b7 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Fri, 21 Oct 2022 20:52:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Ejecuta=20cargo=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagetop/src/app/application.rs | 3 +-- pagetop/src/app/db.rs | 3 +-- pagetop/src/config.rs | 10 ++++------ pagetop/src/config/file/source.rs | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pagetop/src/app/application.rs b/pagetop/src/app/application.rs index 2512da8f..a5c18c4c 100644 --- a/pagetop/src/app/application.rs +++ b/pagetop/src/app/application.rs @@ -55,8 +55,7 @@ impl Application { }) .bind(format!( "{}:{}", - &SETTINGS.webserver.bind_address, - &SETTINGS.webserver.bind_port + &SETTINGS.webserver.bind_address, &SETTINGS.webserver.bind_port ))? .run(); diff --git a/pagetop/src/app/db.rs b/pagetop/src/app/db.rs index 37b3b505..98f96e47 100644 --- a/pagetop/src/app/db.rs +++ b/pagetop/src/app/db.rs @@ -39,8 +39,7 @@ pub static DBCONN: LazyStatic = LazyStatic::new(|| { "sqlite" => DbUri::parse( format!( "{}://{}", - &SETTINGS.database.db_type, - &SETTINGS.database.db_name + &SETTINGS.database.db_type, &SETTINGS.database.db_name ) .as_str(), ) diff --git a/pagetop/src/config.rs b/pagetop/src/config.rs index a372b835..14b6652f 100644 --- a/pagetop/src/config.rs +++ b/pagetop/src/config.rs @@ -136,9 +136,9 @@ use crate::LazyStatic; use crate::config::data::ConfigData; use crate::config::file::File; +use std::collections::HashMap; use std::env; use std::fmt::Debug; -use std::collections::HashMap; use serde::Deserialize; @@ -181,15 +181,12 @@ static CONFIG_DATA: LazyStatic = LazyStatic::new(|| { // Primero añade la configuración común a todos los entornos. Opcional. .merge(File::with_name(&format!("{}/{}.toml", CONFIG_DIR, "common")).required(false)) .unwrap() - // Combina la configuración específica del entorno. Por defecto 'default.toml'. Opcional. .merge(File::with_name(&format!("{}/{}.toml", CONFIG_DIR, run_mode)).required(false)) .unwrap() - // Combina la configuración local. Este archivo no debería incluirse en git. Opcional. .merge(File::with_name(&format!("{}/{}.toml", CONFIG_DIR, "local")).required(false)) .unwrap() - // Salvaguarda el modo de ejecución. .set("app.run_mode", run_mode) .unwrap(); @@ -202,7 +199,8 @@ static CONFIG_DATA: LazyStatic = LazyStatic::new(|| { /// /// Ver [`Cómo añadir ajustes de configuración`](index.html#cómo-añadir-ajustes-de-configuración). pub fn init_settings(values: PredefinedSettings) -> T -where T: Deserialize<'static> +where + T: Deserialize<'static>, { let mut settings = CONFIG_DATA.clone(); for (key, value) in values.iter() { @@ -280,7 +278,7 @@ pub struct Webserver { /// Sección *\[dev\]* de la configuración global. pub struct Dev { /// Valor predefinido: *""* - pub static_files : String, + pub static_files: String, } #[derive(Debug, Deserialize)] diff --git a/pagetop/src/config/file/source.rs b/pagetop/src/config/file/source.rs index e793f4ec..80052c87 100644 --- a/pagetop/src/config/file/source.rs +++ b/pagetop/src/config/file/source.rs @@ -1,12 +1,11 @@ -use std::error::Error; use std::env; +use std::error::Error; use std::fmt::Debug; use std::fs; use std::io::{self, Read}; use std::iter::Iterator; use std::path::{Path, PathBuf}; - /// Describes where the file is sourced. pub trait FileSource: Debug + Clone { fn resolve(&self) -> Result<(Option, String), Box>;