From df38b80bbf32cce78cf6d7725978b9a789882064 Mon Sep 17 00:00:00 2001 From: trivernis Date: Mon, 31 Aug 2020 21:08:35 +0200 Subject: [PATCH] Add book source --- src/bibliography/bib_types/article.rs | 6 ++--- src/bibliography/bib_types/book.rs | 33 +++++++++++++++++++++++++++ src/bibliography/bib_types/mod.rs | 7 +++++- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 src/bibliography/bib_types/book.rs diff --git a/src/bibliography/bib_types/article.rs b/src/bibliography/bib_types/article.rs index 0fee1b2..6b4ca4c 100644 --- a/src/bibliography/bib_types/article.rs +++ b/src/bibliography/bib_types/article.rs @@ -1,4 +1,4 @@ -use chrono::{Local, Date}; +use crate::bibliography::bib_types::LocalDate; /// An article source #[derive(Clone, Debug)] @@ -6,7 +6,7 @@ pub struct Article { pub author: String, pub title: String, pub journal: String, - pub date: Date, + pub date: LocalDate, pub volume: Option, pub number: Option, pub pages: Option, @@ -14,7 +14,7 @@ pub struct Article { impl Article { /// Creates a new article with the mandatory fields filled - pub fn new(author: String, title: String, journal: String, date: Date) -> Self { + pub fn new(author: String, title: String, journal: String, date: LocalDate) -> Self { Self { author, title, diff --git a/src/bibliography/bib_types/book.rs b/src/bibliography/bib_types/book.rs new file mode 100644 index 0000000..cf78ee2 --- /dev/null +++ b/src/bibliography/bib_types/book.rs @@ -0,0 +1,33 @@ +use crate::bibliography::bib_types::LocalDate; + +#[derive(Clone, Debug)] +pub struct Book { + pub author: String, + pub title: String, + pub publisher: String, + pub date: LocalDate, + pub volume: Option, + pub series: Option, + pub address: Option, + pub edition: Option, + pub month: Option, + pub url: Option, +} + +impl Book { + /// Creates a new book with the mandatory fields filled + pub fn new(author: String, title: String, publisher: String, date: LocalDate) -> Self { + Self { + author, + title, + publisher, + date, + volume: None, + series: None, + address: None, + edition: None, + month: None, + url: None, + } + } +} \ No newline at end of file diff --git a/src/bibliography/bib_types/mod.rs b/src/bibliography/bib_types/mod.rs index ba0c863..574a856 100644 --- a/src/bibliography/bib_types/mod.rs +++ b/src/bibliography/bib_types/mod.rs @@ -1,12 +1,17 @@ use crate::bibliography::bib_types::article::Article; +use crate::bibliography::bib_types::book::Book; +use chrono::{Date, Local}; pub mod article; +pub mod book; + +pub type LocalDate = Date; /// A type of bibliography entry #[derive(Clone, Debug)] pub enum BibliographyType { Article(Article), - Book, + Book(Book), Booklet, InBook, InCollection,