use super::util;
use std::collections::HashMap;
#[derive(Clone, Debug, Default)]
pub struct Archive {
pub(crate) entries: HashMap<u32, Vec<u8>>,
}
impl Archive {
pub fn new() -> Self {
Default::default()
}
}
impl Archive {
pub fn contains_key<S>(&self, key: S) -> bool
where
S: Into<String>,
{
let hash = util::entry_hash(key.into());
self.entries.contains_key(&hash)
}
pub fn remove<S>(&mut self, key: S) -> Option<Vec<u8>>
where
S: Into<String>,
{
let hash = util::entry_hash(key.into());
self.entries.remove(&hash)
}
pub fn clear(&mut self) {
self.entries.clear();
}
pub fn len(&self) -> usize {
self.entries.len()
}
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
}