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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
use std::path::{Path, PathBuf};
use crate::{Delta, FileMode, FileStatus, Status};
#[derive(Debug)]
pub struct FileStatusBuilder {
file_status: FileStatus,
}
impl FileStatusBuilder {
#[inline]
#[must_use]
pub fn new() -> Self {
Self {
file_status: FileStatus {
deltas: vec![],
destination_is_binary: false,
destination_mode: FileMode::Normal,
destination_path: PathBuf::default(),
largest_new_line_number: 0,
largest_old_line_number: 0,
source_is_binary: false,
source_mode: FileMode::Normal,
source_path: PathBuf::default(),
status: Status::Added,
},
}
}
#[inline]
#[must_use]
pub fn push_delta(mut self, delta: Delta) -> Self {
self.file_status.add_delta(delta);
self
}
#[inline]
#[must_use]
pub const fn destination_is_binary(mut self, binary: bool) -> Self {
self.file_status.destination_is_binary = binary;
self
}
#[inline]
#[must_use]
pub const fn destination_mode(mut self, mode: FileMode) -> Self {
self.file_status.destination_mode = mode;
self
}
#[inline]
#[must_use]
pub fn destination_path<F: AsRef<Path>>(mut self, path: F) -> Self {
self.file_status.destination_path = PathBuf::from(path.as_ref());
self
}
#[inline]
#[must_use]
pub const fn largest_new_line_number(mut self, largest_new_line_number: u32) -> Self {
self.file_status.largest_new_line_number = largest_new_line_number;
self
}
#[inline]
#[must_use]
pub const fn largest_old_line_number(mut self, largest_old_line_number: u32) -> Self {
self.file_status.largest_old_line_number = largest_old_line_number;
self
}
#[inline]
#[must_use]
pub const fn source_is_binary(mut self, binary: bool) -> Self {
self.file_status.source_is_binary = binary;
self
}
#[inline]
#[must_use]
pub const fn source_mode(mut self, mode: FileMode) -> Self {
self.file_status.source_mode = mode;
self
}
#[inline]
#[must_use]
pub fn source_path<F: AsRef<Path>>(mut self, path: F) -> Self {
self.file_status.source_path = PathBuf::from(path.as_ref());
self
}
#[inline]
#[must_use]
pub const fn status(mut self, status: Status) -> Self {
self.file_status.status = status;
self
}
#[inline]
#[must_use]
#[allow(clippy::missing_const_for_fn)]
pub fn build(self) -> FileStatus {
self.file_status
}
}
impl Default for FileStatusBuilder {
#[inline]
#[must_use]
fn default() -> Self {
Self::new()
}
}