From 40bccf0cbf1d31fa3c75ad526866bba7382ceb9b Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 21 Jul 2021 22:22:33 +0300 Subject: Replace IndexedResult with plain Result --- src/indexedstore.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/indexedstore.rs b/src/indexedstore.rs index b05cfba..c77b552 100644 --- a/src/indexedstore.rs +++ b/src/indexedstore.rs @@ -29,45 +29,42 @@ pub enum IndexedError { SqlError(#[from] StoreError), } -/// A result from an `Index` operation. -pub type IndexedResult = Result; - impl IndexedStore { - pub fn new(dirname: &Path) -> IndexedResult { + pub fn new(dirname: &Path) -> Result { let store = Store::new(dirname); let index = Index::new(dirname)?; Ok(Self { store, index }) } - pub fn save(&mut self, chunk: &DataChunk) -> IndexedResult { + pub fn save(&mut self, chunk: &DataChunk) -> Result { let id = ChunkId::new(); self.store.save(&id, chunk)?; self.insert_meta(&id, chunk.meta())?; Ok(id) } - fn insert_meta(&mut self, id: &ChunkId, meta: &ChunkMeta) -> IndexedResult<()> { + fn insert_meta(&mut self, id: &ChunkId, meta: &ChunkMeta) -> Result<(), IndexedError> { self.index.insert_meta(id.clone(), meta.clone())?; Ok(()) } - pub fn load(&self, id: &ChunkId) -> IndexedResult<(DataChunk, ChunkMeta)> { + pub fn load(&self, id: &ChunkId) -> Result<(DataChunk, ChunkMeta), IndexedError> { Ok((self.store.load(id)?, self.load_meta(id)?)) } - pub fn load_meta(&self, id: &ChunkId) -> IndexedResult { + pub fn load_meta(&self, id: &ChunkId) -> Result { Ok(self.index.get_meta(id)?) } - pub fn find_by_sha256(&self, sha256: &str) -> IndexedResult> { + pub fn find_by_sha256(&self, sha256: &str) -> Result, IndexedError> { Ok(self.index.find_by_sha256(sha256)?) } - pub fn find_generations(&self) -> IndexedResult> { + pub fn find_generations(&self) -> Result, IndexedError> { Ok(self.index.find_generations()?) } - pub fn remove(&mut self, id: &ChunkId) -> IndexedResult<()> { + pub fn remove(&mut self, id: &ChunkId) -> Result<(), IndexedError> { self.index.remove_meta(id)?; self.store.delete(id)?; Ok(()) -- cgit v1.2.1