From 76c682264f566e492b92981a7bae686883d6ec69 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 2 May 2023 13:34:43 +0200 Subject: [PATCH] Derive all struct and enum with debug --- src/config.rs | 4 ++-- src/misc/date.rs | 2 +- src/misc/github.rs | 9 +++++---- src/misc/markdown.rs | 6 +++--- src/routes/agreements.rs | 4 ++-- src/routes/blog.rs | 6 +++--- src/routes/contrib.rs | 6 +++--- src/routes/portfolio.rs | 2 +- src/template.rs | 6 +++--- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/config.rs b/src/config.rs index cbd1cf2..d6601f6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,7 +7,7 @@ use std::{fs::File, io::Write, path::Path}; use crate::template::Template; /// Store the configuration of config/config.toml -#[derive(Deserialize, Clone, Default)] +#[derive(Deserialize, Clone, Default, Debug)] pub struct FileConfig { /// http/https pub scheme: Option, @@ -66,7 +66,7 @@ impl FileConfig { } /// Configuration used internally in the app -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Config { /// Information given in the config file pub fc: FileConfig, diff --git a/src/misc/date.rs b/src/misc/date.rs index a31b229..ae58932 100644 --- a/src/misc/date.rs +++ b/src/misc/date.rs @@ -2,7 +2,7 @@ use chrono::{Datelike, NaiveDate}; use ramhorns::Content; use serde::{Deserialize, Deserializer}; -#[derive(Content, Default)] +#[derive(Content, Default, Debug)] pub struct Date { pub day: u32, pub month: u32, diff --git a/src/misc/github.rs b/src/misc/github.rs index eae1ac6..07d40a8 100644 --- a/src/misc/github.rs +++ b/src/misc/github.rs @@ -5,12 +5,12 @@ use serde::Deserialize; use crate::misc::utils::get_reqwest_client; -#[derive(Deserialize)] +#[derive(Deserialize, Debug)] struct GithubResponse { items: Vec, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug)] struct GithubProject { repository_url: String, number: u32, @@ -19,13 +19,13 @@ struct GithubProject { pull_request: GithubPullRequest, } -#[derive(Deserialize)] +#[derive(Deserialize, Debug)] struct GithubPullRequest { html_url: String, merged_at: Option, } -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub enum ProjectState { Closed = 0, Open = 1, @@ -43,6 +43,7 @@ impl From for ProjectState { } } +#[derive(Debug)] pub struct Project { pub project: String, pub project_url: String, diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index f4a9435..f96dea7 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -8,7 +8,7 @@ use ramhorns::Content; use serde::Deserialize; use std::fs; -#[derive(Default, Deserialize, Content)] +#[derive(Default, Deserialize, Content, Debug)] pub struct FileMetadata { pub title: Option, pub link: Option, @@ -17,7 +17,7 @@ pub struct FileMetadata { pub publish: Option, } -#[derive(Content)] +#[derive(Content, Debug)] pub struct Metadata { pub info: FileMetadata, pub math: bool, @@ -25,7 +25,7 @@ pub struct Metadata { pub syntax_highlight: bool, } -#[derive(Content)] +#[derive(Content, Debug)] pub struct File { pub metadata: Metadata, pub content: String, diff --git a/src/routes/agreements.rs b/src/routes/agreements.rs index e6bcb60..91a87a7 100644 --- a/src/routes/agreements.rs +++ b/src/routes/agreements.rs @@ -13,7 +13,7 @@ pub async fn security(req: HttpRequest, config: web::Data) -> impl Respo )) } -#[derive(Content)] +#[derive(Content, Debug)] struct SecurityTemplate { contact: String, pref_lang: String, @@ -38,7 +38,7 @@ pub async fn humans(config: web::Data) -> impl Responder { HttpResponse::Ok().body(build_humanstxt(config.get_ref().to_owned())) } -#[derive(Content)] +#[derive(Content, Debug)] struct HumansTemplate { contact: String, lang: String, diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 953ea39..e40a4d1 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -34,7 +34,7 @@ pub async fn index(req: HttpRequest, config: web::Data) -> impl Responde )) } -#[derive(Content)] +#[derive(Content, Debug)] struct BlogIndexTemplate { posts: Vec, no_posts: bool, @@ -66,7 +66,7 @@ pub fn build_index(config: Config, url: String) -> String { ) } -#[derive(Content)] +#[derive(Content, Debug)] struct Post { title: String, date: Date, @@ -162,7 +162,7 @@ fn get_posts(location: &str) -> Vec { .collect::>() } -#[derive(Content)] +#[derive(Content, Debug)] struct BlogPostTemplate { post: Option, } diff --git a/src/routes/contrib.rs b/src/routes/contrib.rs index ae54e89..32b37f9 100644 --- a/src/routes/contrib.rs +++ b/src/routes/contrib.rs @@ -18,7 +18,7 @@ pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder HttpResponse::Ok().body(build_page(config.get_ref().to_owned(), url).await) } -#[derive(Content)] +#[derive(Content, Debug)] struct PortfolioTemplate { error: bool, projects: Option>, @@ -26,7 +26,7 @@ struct PortfolioTemplate { closed: Option>, } -#[derive(Content, Clone)] +#[derive(Content, Clone, Debug)] struct Project { name: String, url: String, @@ -35,7 +35,7 @@ struct Project { pulls_closed: Vec, } -#[derive(Content, Clone)] +#[derive(Content, Clone, Debug)] struct Pull { url: String, id: u32, diff --git a/src/routes/portfolio.rs b/src/routes/portfolio.rs index a79b61f..23563e2 100644 --- a/src/routes/portfolio.rs +++ b/src/routes/portfolio.rs @@ -20,7 +20,7 @@ pub async fn page(req: HttpRequest, config: web::Data) -> impl Responder )) } -#[derive(Content)] +#[derive(Content, Debug)] struct PortfolioTemplate<'a> { bots_app: Option>, bots_loc: Option, diff --git a/src/template.rs b/src/template.rs index 6c1af91..c0bc404 100644 --- a/src/template.rs +++ b/src/template.rs @@ -1,7 +1,7 @@ use ramhorns::{Content, Ramhorns}; /// Structure used in the config variable of the app -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Template { /// Root directory where templates are stored pub directory: String, @@ -10,7 +10,7 @@ pub struct Template { } /// Structure used by /routes/*.rs -#[derive(Default)] +#[derive(Default, Debug)] pub struct Infos { /// Title pub page_title: Option, @@ -23,7 +23,7 @@ pub struct Infos { } /// Final structure given to template -#[derive(Content)] +#[derive(Content, Debug)] struct Data { /// App name app_name: String,