diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2021-07-21 21:35:27 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2021-07-21 22:25:50 +0300 |
commit | 50590208fffdc17cd049e1e65f9b293a56343dd5 (patch) | |
tree | 2880a5192dc6c6122c8ea1245924f58cdd8e3814 /src/chunk.rs | |
parent | 24a3284979e41405e213f031ccfcca3f6f1513eb (diff) | |
download | obnam2-50590208fffdc17cd049e1e65f9b293a56343dd5.tar.gz |
Replace GenerationChunkResult with plain Result
Diffstat (limited to 'src/chunk.rs')
-rw-r--r-- | src/chunk.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/chunk.rs b/src/chunk.rs index 8631fd9..469185f 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -51,15 +51,12 @@ pub enum GenerationChunkError { JsonGenerate(serde_json::Error), } -/// A result from a chunk operation. -pub type GenerationChunkResult<T> = Result<T, GenerationChunkError>; - impl GenerationChunk { pub fn new(chunk_ids: Vec<ChunkId>) -> Self { Self { chunk_ids } } - pub fn from_data_chunk(chunk: &DataChunk) -> GenerationChunkResult<Self> { + pub fn from_data_chunk(chunk: &DataChunk) -> Result<Self, GenerationChunkError> { let data = chunk.data(); let data = std::str::from_utf8(data)?; serde_json::from_str(data).map_err(GenerationChunkError::JsonParse) @@ -77,7 +74,7 @@ impl GenerationChunk { self.chunk_ids.iter() } - pub fn to_data_chunk(&self, ended: &str) -> GenerationChunkResult<DataChunk> { + pub fn to_data_chunk(&self, ended: &str) -> Result<DataChunk, GenerationChunkError> { let json: String = serde_json::to_string(self).map_err(GenerationChunkError::JsonGenerate)?; let bytes = json.as_bytes().to_vec(); |