From f9cdf8cc23a42ffd85fba6cb6a7709d2dee37c0b Mon Sep 17 00:00:00 2001 From: Michael Robbins Date: Tue, 21 Nov 2023 19:45:39 +1100 Subject: [PATCH 1/5] Removing second test --- src/config.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index a50cf86..7180c46 100644 --- a/src/config.rs +++ b/src/config.rs @@ -56,10 +56,4 @@ mod tests { let result = 2 + 2; assert_eq!(result, 4); } - - #[test] - fn placeholder2() { - let result = 4 + 2; - assert_eq!(result, 6); - } } \ No newline at end of file From bee7eee9976b2110c34bfd3b2181683ca4758ecd Mon Sep 17 00:00:00 2001 From: Michael Robbins Date: Tue, 21 Nov 2023 19:55:42 +1100 Subject: [PATCH 2/5] Clippy lint --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 7180c46..09602cb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,6 @@ use serde::{Serialize,Deserialize}; use std::fs; use std::process::exit; -use toml; #[derive(Serialize,Deserialize,Clone)] pub struct Data { From 9a6246b4ba3c387cf27ca04d6b1d54ea2155b9ff Mon Sep 17 00:00:00 2001 From: Michael Robbins Date: Tue, 21 Nov 2023 20:00:23 +1100 Subject: [PATCH 3/5] Rustfmt --- src/config.rs | 13 +++++++------ src/main.rs | 8 ++------ src/tasks.rs | 10 ++++------ 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/config.rs b/src/config.rs index 09602cb..619dae0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,28 +1,29 @@ -use serde::{Serialize,Deserialize}; +use serde::{Deserialize, Serialize}; use std::fs; use std::process::exit; -#[derive(Serialize,Deserialize,Clone)] +// Parent struct holding the entire config file +#[derive(Serialize, Deserialize, Clone)] pub struct Data { pub(crate) agent: AgentConfig, category: toml::Table, } // Config struct holds to data from the `[config]` section. -#[derive(Serialize,Deserialize,Clone)] +#[derive(Serialize, Deserialize, Clone)] pub struct AgentConfig { pub name: String, pub port: u16, pub base_path: String, } -#[derive(Serialize,Deserialize,Clone)] +#[derive(Serialize, Deserialize, Clone)] pub struct Categories { pub name: String, pub config: CategoryConfig, } -#[derive(Serialize,Deserialize,Clone)] +#[derive(Serialize, Deserialize, Clone)] pub struct CategoryConfig { pub relative_path: String, } @@ -55,4 +56,4 @@ mod tests { let result = 2 + 2; assert_eq!(result, 4); } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index 3614d77..4cce608 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,7 @@ mod config; mod tasks; -use axum::{ - - routing::get, - Router, -}; +use axum::{routing::get, Router}; use std::net::SocketAddr; #[tokio::main] @@ -29,4 +25,4 @@ async fn main() { .serve(app.into_make_service()) .await .unwrap(); -} \ No newline at end of file +} diff --git a/src/tasks.rs b/src/tasks.rs index 4763f24..e2fef11 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -1,17 +1,15 @@ +use crate::config; use axum::{ + extract::State, http::StatusCode, response::{Html, IntoResponse}, Json, - extract::State, }; -use crate::config; pub async fn help() -> Html<&'static str> { Html("Please visit the documentation for further information") } -pub async fn category_listing( - State(data): State, -) -> impl IntoResponse { +pub async fn category_listing(State(data): State) -> impl IntoResponse { (StatusCode::IM_A_TEAPOT, Json(data)) -} \ No newline at end of file +} From f5241f08e2e36784f10b7100c0cc56b07f537c99 Mon Sep 17 00:00:00 2001 From: Michael Robbins Date: Tue, 21 Nov 2023 20:04:25 +1100 Subject: [PATCH 4/5] Rustfmt --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4cce608..143305a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,6 @@ async fn main() { .route("/api/v1/discover", get(tasks::category_listing)) .with_state(data.clone()); - // run our app with hyper // `axum::Server` is a re-export of `hyper::Server` let addr = SocketAddr::from(([127, 0, 0, 1], data.agent.port)); tracing::debug!("listening on {}", addr); From 58b82357d8c579dc7ffcb73fd404b12a98173477 Mon Sep 17 00:00:00 2001 From: Michael Robbins Date: Tue, 21 Nov 2023 20:06:11 +1100 Subject: [PATCH 5/5] Rustfmt again --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 143305a..63ea281 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,6 @@ async fn main() { .route("/api/v1/discover", get(tasks::category_listing)) .with_state(data.clone()); - // `axum::Server` is a re-export of `hyper::Server` let addr = SocketAddr::from(([127, 0, 0, 1], data.agent.port)); tracing::debug!("listening on {}", addr); axum::Server::bind(&addr)