|
|
@ -1,13 +1,29 @@ |
|
|
|
use std::collections::HashSet; |
|
|
|
use std::collections::HashSet; |
|
|
|
|
|
|
|
use std::hash::{Hash}; |
|
|
|
|
|
|
|
|
|
|
|
use std::fs; |
|
|
|
use std::fs; |
|
|
|
use std::io::{self, Write, BufRead}; |
|
|
|
use std::io::{self, Write, BufRead}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: use this structure in HashSet of items
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash)] |
|
|
|
|
|
|
|
pub struct Item { |
|
|
|
|
|
|
|
pub id: String, |
|
|
|
|
|
|
|
pub content: String |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Item { |
|
|
|
|
|
|
|
pub fn from(s: String) -> Item { |
|
|
|
|
|
|
|
Item { id: s, content: String::from("") } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct DB { |
|
|
|
pub struct DB { |
|
|
|
pub items: HashSet::<String> |
|
|
|
pub items: HashSet::<String> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl DB { |
|
|
|
impl DB { |
|
|
|
pub fn new(path: &str) -> io::Result<DB> { |
|
|
|
pub fn new(path: &str) -> io::Result<DB> { |
|
|
|
let file = fs::File::open(path)?; |
|
|
|
let file = fs::File::open(path)?; |
|
|
|