Welcome to mirror list, hosted at ThFree Co, Russian Federation.

enumerator.rs « src - github.com/windirstat/RustyMft.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 70c4403220f0a0abffb6a8337fb2de41e0df60bc (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
37
38
39
40
41
42
43
44
use std::collections::HashMap;
use rwinstructs::reference::{MftReference};

#[derive(Hash, Eq, PartialEq, Debug, Clone)]
pub struct PathMapping {
    pub name: String,
    pub parent: MftReference,
}

pub struct PathEnumerator {
    pub mapping: HashMap<MftReference,PathMapping>
}

impl PathEnumerator {
    pub fn new() -> PathEnumerator {
        PathEnumerator{
            mapping: HashMap::new()
        }
    }

    pub fn get_mapping(&self, reference: MftReference) -> Option<PathMapping> {
        match self.mapping.get(&reference) {
            Some(value) => Some(value.clone()),
            None => None
        }
    }

    pub fn print_mapping(&self){
        println!("{:?}",self.mapping);
    }

    pub fn contains_mapping(&self, reference: MftReference) -> bool {
        self.mapping.contains_key(
            &reference
        )
    }

    pub fn set_mapping(&mut self, reference: MftReference, mapping: PathMapping) {
        self.mapping.insert(
            reference,
            mapping
        );
    }
}