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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
mod impls {
use std::ops::{Deref, DerefMut};
use crate::{File, State};
impl Deref for File {
type Target = State;
fn deref(&self) -> &Self::Target {
&self.state
}
}
impl DerefMut for File {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.state
}
}
}
mod impl_ {
use std::fmt::Formatter;
use crate::{File, State};
impl std::fmt::Debug for File {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("File")
.field("path", &self.path.display())
.field("checksum", &self.checksum)
.finish_non_exhaustive()
}
}
impl From<File> for State {
fn from(f: File) -> Self {
f.state
}
}
}
mod access {
use crate::File;
impl File {
pub fn into_parts(self) -> (crate::State, std::path::PathBuf) {
(self.state, self.path)
}
}
impl File {
pub fn path(&self) -> &std::path::Path {
&self.path
}
pub fn checksum(&self) -> Option<gix_hash::ObjectId> {
self.checksum
}
}
}
mod mutation {
use std::path::PathBuf;
use crate::File;
impl File {
pub fn set_path(&mut self, path: impl Into<PathBuf>) {
self.path = path.into();
}
}
}
pub mod init;
pub mod verify;
pub mod write;