|
|
|
@ -53,7 +53,8 @@ impl Ord for Item {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub struct DB { |
|
|
|
|
pub items: HashSet::<Item> |
|
|
|
|
pub items: HashSet::<Item>, |
|
|
|
|
path: String |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl DB { |
|
|
|
@ -72,7 +73,8 @@ impl DB {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let result = DB { |
|
|
|
|
items: items |
|
|
|
|
items: items, |
|
|
|
|
path: String::from(path) |
|
|
|
|
}; |
|
|
|
|
Ok(result) |
|
|
|
|
} |
|
|
|
@ -82,11 +84,11 @@ impl DB {
|
|
|
|
|
self.items.contains(&item) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn dump(&self, path: &str) -> io::Result<()> { |
|
|
|
|
pub fn dump(&self) -> io::Result<()> { |
|
|
|
|
let mut file = fs::OpenOptions::new() |
|
|
|
|
.write(true) |
|
|
|
|
.append(false) |
|
|
|
|
.open(path)?; |
|
|
|
|
.open(&self.path)?; |
|
|
|
|
|
|
|
|
|
for item in self.items.iter() { |
|
|
|
|
writeln!(file, "{}", item.id)?; |
|
|
|
|