diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2021-07-21 21:47:52 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2021-07-21 22:25:50 +0300 |
commit | 1594f6d32393eebf282402174c0b2092b8081dd6 (patch) | |
tree | 26241fbe3b1ec8e461557203dc1f08b24d0142d8 /src | |
parent | 50590208fffdc17cd049e1e65f9b293a56343dd5 (diff) | |
download | obnam2-1594f6d32393eebf282402174c0b2092b8081dd6.tar.gz |
Replace ChunkerResult with plain Result
Diffstat (limited to 'src')
-rw-r--r-- | src/chunker.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/chunker.rs b/src/chunker.rs index a7a39f1..763c148 100644 --- a/src/chunker.rs +++ b/src/chunker.rs @@ -17,8 +17,6 @@ pub enum ChunkerError { FileRead(PathBuf, std::io::Error), } -pub type ChunkerResult<T> = Result<T, ChunkerError>; - impl Chunker { pub fn new(chunk_size: usize, handle: std::fs::File, filename: &Path) -> Self { let mut buf = vec![]; @@ -31,7 +29,7 @@ impl Chunker { } } - pub fn read_chunk(&mut self) -> ChunkerResult<Option<DataChunk>> { + pub fn read_chunk(&mut self) -> Result<Option<DataChunk>, ChunkerError> { let mut used = 0; loop { @@ -58,9 +56,9 @@ impl Chunker { } impl Iterator for Chunker { - type Item = ChunkerResult<DataChunk>; + type Item = Result<DataChunk, ChunkerError>; - fn next(&mut self) -> Option<ChunkerResult<DataChunk>> { + fn next(&mut self) -> Option<Result<DataChunk, ChunkerError>> { match self.read_chunk() { Ok(None) => None, Ok(Some(chunk)) => Some(Ok(chunk)), |