Derive all struct and enum with debug
This commit is contained in:
parent
36d4889983
commit
76c682264f
9 changed files with 23 additions and 22 deletions
|
@ -7,7 +7,7 @@ use std::{fs::File, io::Write, path::Path};
|
||||||
use crate::template::Template;
|
use crate::template::Template;
|
||||||
|
|
||||||
/// Store the configuration of config/config.toml
|
/// Store the configuration of config/config.toml
|
||||||
#[derive(Deserialize, Clone, Default)]
|
#[derive(Deserialize, Clone, Default, Debug)]
|
||||||
pub struct FileConfig {
|
pub struct FileConfig {
|
||||||
/// http/https
|
/// http/https
|
||||||
pub scheme: Option<String>,
|
pub scheme: Option<String>,
|
||||||
|
@ -66,7 +66,7 @@ impl FileConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration used internally in the app
|
/// Configuration used internally in the app
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Information given in the config file
|
/// Information given in the config file
|
||||||
pub fc: FileConfig,
|
pub fc: FileConfig,
|
||||||
|
|
|
@ -2,7 +2,7 @@ use chrono::{Datelike, NaiveDate};
|
||||||
use ramhorns::Content;
|
use ramhorns::Content;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
#[derive(Content, Default)]
|
#[derive(Content, Default, Debug)]
|
||||||
pub struct Date {
|
pub struct Date {
|
||||||
pub day: u32,
|
pub day: u32,
|
||||||
pub month: u32,
|
pub month: u32,
|
||||||
|
|
|
@ -5,12 +5,12 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use crate::misc::utils::get_reqwest_client;
|
use crate::misc::utils::get_reqwest_client;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct GithubResponse {
|
struct GithubResponse {
|
||||||
items: Vec<GithubProject>,
|
items: Vec<GithubProject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct GithubProject {
|
struct GithubProject {
|
||||||
repository_url: String,
|
repository_url: String,
|
||||||
number: u32,
|
number: u32,
|
||||||
|
@ -19,13 +19,13 @@ struct GithubProject {
|
||||||
pull_request: GithubPullRequest,
|
pull_request: GithubPullRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Debug)]
|
||||||
struct GithubPullRequest {
|
struct GithubPullRequest {
|
||||||
html_url: String,
|
html_url: String,
|
||||||
merged_at: Option<String>,
|
merged_at: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum ProjectState {
|
pub enum ProjectState {
|
||||||
Closed = 0,
|
Closed = 0,
|
||||||
Open = 1,
|
Open = 1,
|
||||||
|
@ -43,6 +43,7 @@ impl From<u8> for ProjectState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Project {
|
pub struct Project {
|
||||||
pub project: String,
|
pub project: String,
|
||||||
pub project_url: String,
|
pub project_url: String,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use ramhorns::Content;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Default, Deserialize, Content)]
|
#[derive(Default, Deserialize, Content, Debug)]
|
||||||
pub struct FileMetadata {
|
pub struct FileMetadata {
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
pub link: Option<String>,
|
pub link: Option<String>,
|
||||||
|
@ -17,7 +17,7 @@ pub struct FileMetadata {
|
||||||
pub publish: Option<bool>,
|
pub publish: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
pub struct Metadata {
|
pub struct Metadata {
|
||||||
pub info: FileMetadata,
|
pub info: FileMetadata,
|
||||||
pub math: bool,
|
pub math: bool,
|
||||||
|
@ -25,7 +25,7 @@ pub struct Metadata {
|
||||||
pub syntax_highlight: bool,
|
pub syntax_highlight: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub metadata: Metadata,
|
pub metadata: Metadata,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub async fn security(req: HttpRequest, config: web::Data<Config>) -> impl Respo
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct SecurityTemplate {
|
struct SecurityTemplate {
|
||||||
contact: String,
|
contact: String,
|
||||||
pref_lang: String,
|
pref_lang: String,
|
||||||
|
@ -38,7 +38,7 @@ pub async fn humans(config: web::Data<Config>) -> impl Responder {
|
||||||
HttpResponse::Ok().body(build_humanstxt(config.get_ref().to_owned()))
|
HttpResponse::Ok().body(build_humanstxt(config.get_ref().to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct HumansTemplate {
|
struct HumansTemplate {
|
||||||
contact: String,
|
contact: String,
|
||||||
lang: String,
|
lang: String,
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub async fn index(req: HttpRequest, config: web::Data<Config>) -> impl Responde
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct BlogIndexTemplate {
|
struct BlogIndexTemplate {
|
||||||
posts: Vec<Post>,
|
posts: Vec<Post>,
|
||||||
no_posts: bool,
|
no_posts: bool,
|
||||||
|
@ -66,7 +66,7 @@ pub fn build_index(config: Config, url: String) -> String {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct Post {
|
struct Post {
|
||||||
title: String,
|
title: String,
|
||||||
date: Date,
|
date: Date,
|
||||||
|
@ -162,7 +162,7 @@ fn get_posts(location: &str) -> Vec<Post> {
|
||||||
.collect::<Vec<Post>>()
|
.collect::<Vec<Post>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct BlogPostTemplate {
|
struct BlogPostTemplate {
|
||||||
post: Option<File>,
|
post: Option<File>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder
|
||||||
HttpResponse::Ok().body(build_page(config.get_ref().to_owned(), url).await)
|
HttpResponse::Ok().body(build_page(config.get_ref().to_owned(), url).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct PortfolioTemplate {
|
struct PortfolioTemplate {
|
||||||
error: bool,
|
error: bool,
|
||||||
projects: Option<Vec<Project>>,
|
projects: Option<Vec<Project>>,
|
||||||
|
@ -26,7 +26,7 @@ struct PortfolioTemplate {
|
||||||
closed: Option<Vec<Project>>,
|
closed: Option<Vec<Project>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content, Clone)]
|
#[derive(Content, Clone, Debug)]
|
||||||
struct Project {
|
struct Project {
|
||||||
name: String,
|
name: String,
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -35,7 +35,7 @@ struct Project {
|
||||||
pulls_closed: Vec<Pull>,
|
pulls_closed: Vec<Pull>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content, Clone)]
|
#[derive(Content, Clone, Debug)]
|
||||||
struct Pull {
|
struct Pull {
|
||||||
url: String,
|
url: String,
|
||||||
id: u32,
|
id: u32,
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub async fn page(req: HttpRequest, config: web::Data<Config>) -> impl Responder
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct PortfolioTemplate<'a> {
|
struct PortfolioTemplate<'a> {
|
||||||
bots_app: Option<Vec<File>>,
|
bots_app: Option<Vec<File>>,
|
||||||
bots_loc: Option<String>,
|
bots_loc: Option<String>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use ramhorns::{Content, Ramhorns};
|
use ramhorns::{Content, Ramhorns};
|
||||||
|
|
||||||
/// Structure used in the config variable of the app
|
/// Structure used in the config variable of the app
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Template {
|
pub struct Template {
|
||||||
/// Root directory where templates are stored
|
/// Root directory where templates are stored
|
||||||
pub directory: String,
|
pub directory: String,
|
||||||
|
@ -10,7 +10,7 @@ pub struct Template {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure used by /routes/*.rs
|
/// Structure used by /routes/*.rs
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
pub struct Infos {
|
pub struct Infos {
|
||||||
/// Title
|
/// Title
|
||||||
pub page_title: Option<String>,
|
pub page_title: Option<String>,
|
||||||
|
@ -23,7 +23,7 @@ pub struct Infos {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Final structure given to template
|
/// Final structure given to template
|
||||||
#[derive(Content)]
|
#[derive(Content, Debug)]
|
||||||
struct Data<T> {
|
struct Data<T> {
|
||||||
/// App name
|
/// App name
|
||||||
app_name: String,
|
app_name: String,
|
||||||
|
|
Loading…
Reference in a new issue