From 500c06609b2408fed801840983e261fd87b15ebe Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 21 Jul 2021 20:45:32 +0300 Subject: In errors, store chunk ids as `ChunkId`, not `String` Fixes #114. --- src/client.rs | 4 ++-- src/genlist.rs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index b1f9976..92d825f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -27,10 +27,10 @@ pub enum ClientError { NotFound(String), #[error("Server does not have chunk {0}")] - ChunkNotFound(String), + ChunkNotFound(ChunkId), #[error("Server does not have generation {0}")] - GenerationNotFound(String), + GenerationNotFound(ChunkId), #[error("Server response did not have a 'chunk-meta' header for chunk {0}")] NoChunkMeta(ChunkId), diff --git a/src/genlist.rs b/src/genlist.rs index 9d7e39d..21f558c 100644 --- a/src/genlist.rs +++ b/src/genlist.rs @@ -8,7 +8,7 @@ pub struct GenerationList { #[derive(Debug, thiserror::Error)] pub enum GenerationListError { #[error("Unknown generation: {0}")] - UnknownGeneration(String), + UnknownGeneration(ChunkId), } impl GenerationList { @@ -42,7 +42,9 @@ impl GenerationList { } }; match gen { - None => Err(GenerationListError::UnknownGeneration(genref.to_string())), + None => Err(GenerationListError::UnknownGeneration(ChunkId::recreate( + genref, + ))), Some(gen) => Ok(gen.id().to_string()), } } -- cgit v1.2.1