diff options
Diffstat (limited to 'src/index.rs')
| -rw-r--r-- | src/index.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/index.rs b/src/index.rs index 616682d..9f0af1d 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1,3 +1,4 @@ +use std::fmt::{Formatter, Debug, Result}; use std::fs::File; use std::io::{Write, BufReader, BufRead}; use walkdir::*; @@ -14,12 +15,26 @@ use crate::vector; /// Represents a Index which is ether generated /// or read from a file. +#[derive(Clone, Debug)] pub struct Index { dictionary : Dictionary, filecache : Vec<FileCache>, } +impl Default for Index { + fn default() -> Self { + Self::empty() + } +} + impl Index { + pub fn empty() -> Self { + Self { + dictionary : Dictionary::new(), + filecache : Vec::new() + } + } + pub fn generate(input_path : &str, index_path : &str, callback : impl Fn(u64, u64)) -> Self { let mut index_file = File::create(index_path).unwrap(); let mut dict = Dictionary::new(); |