aboutsummaryrefslogtreecommitdiff
path: root/src/index.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-07-07 00:26:54 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-07-07 00:26:54 +0200
commit179920fa402b81a3ae8cc3c4b415172f71eb8d11 (patch)
tree33bd4cb4cceb58ef65ae19a6c8d0f3e4e0ea53ec /src/index.rs
parent9b4aa4e9643b0a5b4a554e455eac269a2472b590 (diff)
add gui
Diffstat (limited to 'src/index.rs')
-rw-r--r--src/index.rs15
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();