From 899ef119d3d0524f6d33168778f09e1318917850 Mon Sep 17 00:00:00 2001 From: "Gerard Castillo Lasheras (BI X)" Date: Tue, 9 Jan 2024 11:28:56 +0100 Subject: [PATCH] fix cargo fmt check --- be-rust-axum/rust-template/src/api/router.rs | 20 +++++++++---------- .../rust-template/src/config/settings.rs | 18 ++++++++--------- .../rust-template/src/models/status.rs | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/be-rust-axum/rust-template/src/api/router.rs b/be-rust-axum/rust-template/src/api/router.rs index 7e906a444..5e0d3b08f 100644 --- a/be-rust-axum/rust-template/src/api/router.rs +++ b/be-rust-axum/rust-template/src/api/router.rs @@ -24,8 +24,8 @@ pub async fn serve(address: SocketAddr) { info!("Server listening on {}", &address); axum::serve(listener, app().into_make_service()) - .with_graceful_shutdown(shutdown_signal()) - .await + .with_graceful_shutdown(shutdown_signal()) + .await .expect("Failed to start server"); } @@ -42,16 +42,16 @@ async fn fallback() -> (StatusCode, Json) { /// Setup example of the OS signal handlers to catch for proper server graceful shutdown. async fn shutdown_signal() { let interrupt = async { - signal(SignalKind::interrupt()) - .expect("failed to install signal handler") - .recv() - .await; + signal(SignalKind::interrupt()) + .expect("failed to install signal handler") + .recv() + .await; }; let terminate = async { - signal(SignalKind::terminate()) - .expect("failed to install signal handler") - .recv() - .await; + signal(SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; }; tokio::select! { _ = interrupt => {}, diff --git a/be-rust-axum/rust-template/src/config/settings.rs b/be-rust-axum/rust-template/src/config/settings.rs index 9a8a5c030..eb2c741a2 100644 --- a/be-rust-axum/rust-template/src/config/settings.rs +++ b/be-rust-axum/rust-template/src/config/settings.rs @@ -5,24 +5,24 @@ use tracing::Level; lazy_static! { /// The lazy loaded static Settings struct that calls `Settings::load()` when the app starts, /// and that is used whenever a configuration attribute is required within the app. - pub static ref SETTINGS: Settings = Settings::load(); + pub static ref SETTINGS: Settings = Settings::load(); } /// The Settings struct where the required config for our app is loaded into #[derive(Deserialize, Debug)] pub struct Settings { - /// The server port to listen to - must be u16 (number). - /// - /// Defaults to 8080 + /// The server port to listen to - must be u16 (number). + /// + /// Defaults to 8080 pub port: u16, - /// The server global log_level - must be either "TRACE", "DEBUG", "INFO", "WARN" or "ERROR". - /// - /// Defaults to DEBUG + /// The server global log_level - must be either "TRACE", "DEBUG", "INFO", "WARN" or "ERROR". + /// + /// Defaults to DEBUG pub log_level: String, } impl Settings { - /// Creates/loads the `Settings` with the configuration parameters required for the app + /// Creates/loads the `Settings` with the configuration parameters required for the app pub fn load() -> Self { Settings { port: std::env::var("PORT") @@ -33,7 +33,7 @@ impl Settings { } } - /// Translates the `log_level` String to the proper `tracing::Level` value. + /// Translates the `log_level` String to the proper `tracing::Level` value. pub fn log_level(&self) -> Level { match self.log_level.as_str() { "ERROR" => Level::ERROR, diff --git a/be-rust-axum/rust-template/src/models/status.rs b/be-rust-axum/rust-template/src/models/status.rs index fa471345d..211ad6376 100644 --- a/be-rust-axum/rust-template/src/models/status.rs +++ b/be-rust-axum/rust-template/src/models/status.rs @@ -3,6 +3,6 @@ use serde::{Deserialize, Serialize}; /// The Status object used to inform about the health of the app #[derive(Serialize, Deserialize, Debug)] pub struct Status { - /// the `status` String - being for now always `Ok` if one can reach endpoint + /// the `status` String - being for now always `Ok` if one can reach endpoint pub status: String, }