|
|
|
@ -1,4 +1,8 @@
|
|
|
|
|
use crate::utils::date::LocalDate;
|
|
|
|
|
use crate::bibliography::keys::{K_ADDRESS, K_AUTHOR, K_DATE, K_HOW_PUBLISHED, K_TITLE};
|
|
|
|
|
use crate::bibliography::FromHashMap;
|
|
|
|
|
use crate::utils::date::{parse_date, LocalDate};
|
|
|
|
|
use std::collections::hash_map::RandomState;
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
/// A booklet source where only the title can be known
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
@ -22,3 +26,25 @@ impl Booklet {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl FromHashMap for Booklet {
|
|
|
|
|
fn from_hash_map(map: &HashMap<String, String, RandomState>) -> Option<Box<Self>> {
|
|
|
|
|
let title = map.get(K_TITLE)?;
|
|
|
|
|
let mut booklet = Booklet::new(title.clone());
|
|
|
|
|
|
|
|
|
|
if let Some(author) = map.get(K_AUTHOR) {
|
|
|
|
|
booklet.author = Some(author.clone())
|
|
|
|
|
}
|
|
|
|
|
if let Some(how_published) = map.get(K_HOW_PUBLISHED) {
|
|
|
|
|
booklet.how_published = Some(how_published.clone());
|
|
|
|
|
}
|
|
|
|
|
if let Some(address) = map.get(K_ADDRESS) {
|
|
|
|
|
booklet.address = Some(address.clone());
|
|
|
|
|
}
|
|
|
|
|
if let Some(date) = map.get(K_DATE) {
|
|
|
|
|
booklet.date = parse_date(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Some(Box::new(booklet))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|