blob: af97c204d1fdf87b676d307761f63b4d53400cf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
use std::hash::{Hasher, Hash};
use crate::vector::FileVector;
/// Represents one file which was indexed.
#[derive(Clone, Debug, Default)]
pub struct FileCache {
pub path : String,
pub vector : FileVector,
}
impl PartialEq for FileCache {
fn eq(&self, other : &Self) -> bool {
self.path == other.path
}
}
impl Eq for FileCache { }
impl Hash for FileCache {
fn hash<H: Hasher>(&self, state: &mut H) {
self.path.hash(state);
}
}
impl FileCache {
pub fn from_line(line : String) -> Self {
let ls : Vec<String> = line.split(',').map(|s| s.to_string()).collect();
let v = FileVector::from_string(&ls[1]);
let p = ls[0].clone().replace('\0', ",");
Self {
vector : v,
path : p
}
}
}
|