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