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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use super::*;
use std::rc::Rc;

mod ser_der;
mod try_from;

#[derive(Eq)]
pub struct FileID(Rc<str>);

impl Clone for FileID {
    fn clone(&self) -> Self {
        FileID(self.0.clone())
    }
}

impl Default for FileID {
    fn default() -> Self {
        Self(Rc::from(String::new()))
    }
}

impl AsRef<str> for FileID {
    fn as_ref(&self) -> &str {
        &self.0
    }
}

impl FileID {
    pub fn new<E>(source: E) -> Result<Self, <E as TryInto<Self>>::Error>
    where
        E: TryInto<Self>,
    {
        source.try_into()
    }
}

impl Debug for FileID {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.debug_tuple("FileID").field(&self.0).finish()
    }
}

impl Display for FileID {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}

impl Hash for FileID {
    fn hash<H: Hasher>(&self, state: &mut H) {
        state.write(self.0.as_bytes())
    }
}

impl PartialEq for FileID {
    fn eq(&self, other: &Self) -> bool {
        self.0.eq(&other.0)
    }
}

impl PartialOrd for FileID {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        self.0.partial_cmp(&other.0)
    }
}

impl Ord for FileID {
    fn cmp(&self, other: &Self) -> Ordering {
        self.0.cmp(&other.0)
    }
}