|
|
@ -1,4 +1,6 @@
|
|
|
|
use crate::bibliography::bibliography_entry::{BibliographyEntry, BibliographyEntryReference};
|
|
|
|
use crate::bibliography::bibliography_entry::{BibliographyEntry, BibliographyEntryReference};
|
|
|
|
|
|
|
|
use crate::bibliography::keys::K_KEY;
|
|
|
|
|
|
|
|
use crate::bibliography::FromHashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
|
|
|
|
|
|
@ -22,12 +24,18 @@ impl BibliographyDictionary {
|
|
|
|
.insert(entry.key(), Arc::new(Mutex::new(entry)));
|
|
|
|
.insert(entry.key(), Arc::new(Mutex::new(entry)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Inserts a bibliography entry represented as a HashMap
|
|
|
|
|
|
|
|
pub fn insert_map(&mut self, map: &HashMap<String, String>) -> Option<()> {
|
|
|
|
|
|
|
|
let key = map.get(K_KEY)?;
|
|
|
|
|
|
|
|
let entry = *BibliographyEntry::from_hash_map(map)?;
|
|
|
|
|
|
|
|
self.entries
|
|
|
|
|
|
|
|
.insert(key.clone(), Arc::new(Mutex::new(entry)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Some(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the reference to the bibliography entry with the given key
|
|
|
|
/// Returns the reference to the bibliography entry with the given key
|
|
|
|
pub fn get(&mut self, key: &str) -> Option<BibliographyEntryReference> {
|
|
|
|
pub fn get(&mut self, key: &str) -> Option<BibliographyEntryReference> {
|
|
|
|
if let Some(entry) = self.entries.get(&key.to_string()) {
|
|
|
|
self.entries.get(&key.to_string()).cloned()
|
|
|
|
Some(Arc::clone(entry))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
None
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|