Skip to content

Commit 2f76858

Browse files
fix naming
1 parent be2b9f6 commit 2f76858

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/io/track_progress.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ use crate::Progress;
2525
/// The progress callback will never overshoot.
2626
pub struct TrackProgressReader<R, F> {
2727
inner: R,
28-
loaded: u64,
29-
approximate_total: u64,
3028
on_progress: F,
3129
complete_on_drop: bool,
30+
loaded_bytes: u64,
31+
approximate_total_bytes: u64,
3232
}
3333

3434
/// A byte writer, like a file or a network stream.
@@ -38,10 +38,10 @@ pub struct TrackProgressReader<R, F> {
3838
/// The progress callback will never overshoot.
3939
pub struct TrackProgressWriter<R, F> {
4040
inner: R,
41-
loaded: u64,
42-
approximate_total: u64,
4341
on_progress: F,
4442
complete_on_drop: bool,
43+
written_bytes: u64,
44+
approximate_total_bytes: u64,
4545
}
4646

4747
impl<F> TrackProgressReader<File, F> {
@@ -52,9 +52,9 @@ impl<F> TrackProgressReader<File, F> {
5252
Self {
5353
on_progress,
5454
inner: file,
55-
approximate_total: file.metadata()?.len(),
55+
approximate_total_bytes: file.metadata()?.len(),
5656
complete_on_drop: true,
57-
loaded: 0,
57+
loaded_bytes: 0,
5858
}
5959
}
6060
}
@@ -65,9 +65,9 @@ impl<R: Read, F> TrackProgressReader<R, F> {
6565
Self {
6666
on_progress,
6767
inner,
68-
approximate_total: file_size,
68+
approximate_total_bytes: file_size,
6969
complete_on_drop: true,
70-
loaded: 0,
70+
loaded_bytes: 0,
7171
}
7272
}
7373

@@ -78,7 +78,7 @@ impl<R: Read, F> TrackProgressReader<R, F> {
7878

7979
/// Called after meta data was read, but before reading the content of the file.
8080
pub fn update_expected_size(&mut self, file_size: u64){
81-
self.approximate_total = file_size;
81+
self.approximate_total_bytes = file_size;
8282
}
8383
}
8484

@@ -88,9 +88,9 @@ impl<W: Write, F> TrackProgressWriter<W, F> {
8888
Self {
8989
inner,
9090
on_progress,
91-
approximate_total: estimated_compressed_file_size,
91+
approximate_total_bytes: estimated_compressed_file_size,
9292
complete_on_drop: true,
93-
loaded: 0,
93+
written_bytes: 0,
9494
}
9595
}
9696

@@ -108,8 +108,8 @@ impl<R,F> Read for TrackProgressReader<R, F>
108108

109109
if let Some(&count) = &result {
110110
// report progress of the bytes that have definitely been processed
111-
self.on_progress(new_progress(self.loaded, self.approximate_total));
112-
self.loaded += count;
111+
self.on_progress(new_progress(self.loaded_bytes, self.approximate_total_bytes));
112+
self.loaded_bytes += count;
113113
}
114114

115115
result
@@ -124,10 +124,10 @@ impl<W,F> Write for TrackProgressWriter<W, F>
124124
let result = self.inner.write(buffer);
125125

126126
if let Some(&count) = &result {
127-
self.loaded += count;
127+
self.written_bytes += count;
128128

129129
// report progress of written state
130-
self.on_progress(new_progress(self.loaded, self.approximate_total));
130+
self.on_progress(new_progress(self.written_bytes, self.approximate_total_bytes));
131131
}
132132

133133
result
@@ -141,15 +141,15 @@ impl<W,F> Write for TrackProgressWriter<W, F>
141141
impl<R, F: FnMut(Progress)> Drop for TrackProgressReader<R, F> {
142142
fn drop(&mut self) {
143143
if self.complete_on_drop {
144-
self.on_progress(complete_progress(self.approximate_total))
144+
self.on_progress(complete_progress(self.approximate_total_bytes))
145145
}
146146
}
147147
}
148148

149149
impl<W, F: FnMut(Progress)> Drop for TrackProgressWriter<W, F> {
150150
fn drop(&mut self) {
151151
if self.complete_on_drop {
152-
self.on_progress(complete_progress(self.approximate_total))
152+
self.on_progress(complete_progress(self.approximate_total_bytes))
153153
}
154154
}
155155
}

0 commit comments

Comments
 (0)