From cbdc84ba790d9a9aec26d9c6194f279b6280486b Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 1 Sep 2020 21:11:28 +0200 Subject: [PATCH] Add Misc source type Signed-off-by: trivernis --- src/bibliography/bib_types/misc.rs | 22 ++++++++++++++++++++++ src/bibliography/bib_types/mod.rs | 4 +++- src/bibliography/bibliography_entry.rs | 3 ++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/bibliography/bib_types/misc.rs diff --git a/src/bibliography/bib_types/misc.rs b/src/bibliography/bib_types/misc.rs new file mode 100644 index 0000000..2b19915 --- /dev/null +++ b/src/bibliography/bib_types/misc.rs @@ -0,0 +1,22 @@ +use crate::bibliography::bib_types::LocalDate; + +/// A source that does not fit any of the other types +#[derive(Clone, Debug)] +pub struct Misc { + pub author: Option, + pub title: Option, + pub how_published: Option, + pub date: Option, +} + +impl Misc { + /// Creates an empty Misc + pub fn new() -> Self { + Self { + author: None, + title: None, + how_published: None, + date: None, + } + } +} diff --git a/src/bibliography/bib_types/mod.rs b/src/bibliography/bib_types/mod.rs index 9cb6108..d53ffb9 100644 --- a/src/bibliography/bib_types/mod.rs +++ b/src/bibliography/bib_types/mod.rs @@ -4,6 +4,7 @@ use crate::bibliography::bib_types::booklet::Booklet; use crate::bibliography::bib_types::in_book::InBook; use crate::bibliography::bib_types::in_collection::InCollection; use crate::bibliography::bib_types::manual::Manual; +use crate::bibliography::bib_types::misc::Misc; use crate::bibliography::bib_types::tech_report::TechReport; use crate::bibliography::bib_types::thesis::Thesis; use crate::bibliography::bib_types::unpublished::Unpublished; @@ -15,6 +16,7 @@ pub mod booklet; pub mod in_book; pub mod in_collection; pub mod manual; +pub mod misc; pub mod tech_report; pub mod thesis; pub mod unpublished; @@ -33,7 +35,7 @@ pub enum BibliographyType { Thesis(Thesis), TechReport(TechReport), Unpublished(Unpublished), - Misc, + Misc(Misc), Url, Repository, } diff --git a/src/bibliography/bibliography_entry.rs b/src/bibliography/bibliography_entry.rs index ffe6f46..04c43aa 100644 --- a/src/bibliography/bibliography_entry.rs +++ b/src/bibliography/bibliography_entry.rs @@ -1,3 +1,4 @@ +use crate::bibliography::bib_types::misc::Misc; use crate::bibliography::bib_types::BibliographyType; use std::sync::{Arc, Mutex}; @@ -17,7 +18,7 @@ impl BibliographyEntry { Self { key, note: None, - bib_type: BibliographyType::Misc, + bib_type: BibliographyType::Misc(Misc::new()), } }