1#[allow(unused_imports)]
2use log::{debug, error, info, trace, warn};
3pub struct SourceHash {
4 hashvalue: String,
5}
6
7impl SourceHash {
8 #[must_use]
9 pub fn new(src: &str) -> Self {
10 Self {
11 hashvalue: src.to_owned(),
12 }
13 }
14 #[must_use]
15 pub fn has_changed(&self, new: &str) -> bool {
16 trace!(
17 "Old and new lengths: {}, {}",
18 self.hashvalue.len(),
19 new.len()
20 );
21 !self.hashvalue.eq(new)
22 }
23}
24
25pub struct Hashes {
26 pub passwd: SourceHash,
27 pub shadow: SourceHash,
28 pub group: SourceHash,
29}
30
31impl Hashes {
32 #[must_use]
33 pub fn new(passwd: &str, shadow: &str, group: &str) -> Self {
34 Self {
35 passwd: SourceHash::new(passwd),
36 shadow: SourceHash::new(shadow),
37 group: SourceHash::new(group),
38 }
39 }
40}