Add book source

main
trivernis 4 years ago
parent dec84de7ce
commit df38b80bbf

@ -1,4 +1,4 @@
use chrono::{Local, Date}; use crate::bibliography::bib_types::LocalDate;
/// An article source /// An article source
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -6,7 +6,7 @@ pub struct Article {
pub author: String, pub author: String,
pub title: String, pub title: String,
pub journal: String, pub journal: String,
pub date: Date<Local>, pub date: LocalDate,
pub volume: Option<String>, pub volume: Option<String>,
pub number: Option<String>, pub number: Option<String>,
pub pages: Option<String>, pub pages: Option<String>,
@ -14,7 +14,7 @@ pub struct Article {
impl Article { impl Article {
/// Creates a new article with the mandatory fields filled /// Creates a new article with the mandatory fields filled
pub fn new(author: String, title: String, journal: String, date: Date<Local>) -> Self { pub fn new(author: String, title: String, journal: String, date: LocalDate) -> Self {
Self { Self {
author, author,
title, title,

@ -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<String>,
pub series: Option<String>,
pub address: Option<String>,
pub edition: Option<String>,
pub month: Option<String>,
pub url: Option<String>,
}
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,
}
}
}

@ -1,12 +1,17 @@
use crate::bibliography::bib_types::article::Article; use crate::bibliography::bib_types::article::Article;
use crate::bibliography::bib_types::book::Book;
use chrono::{Date, Local};
pub mod article; pub mod article;
pub mod book;
pub type LocalDate = Date<Local>;
/// A type of bibliography entry /// A type of bibliography entry
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum BibliographyType { pub enum BibliographyType {
Article(Article), Article(Article),
Book, Book(Book),
Booklet, Booklet,
InBook, InBook,
InCollection, InCollection,

Loading…
Cancel
Save