summaryrefslogtreecommitdiff
path: root/src/indexedstore.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-23 19:35:23 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-23 19:35:23 +0200
commit345c5d822776ef78e594c2365d8bfd39202952e0 (patch)
tree37fbdb673eb03c63c8a909540a885d82d0225357 /src/indexedstore.rs
parent4128b937a6bd1ea3944a6a7f00930d40f27f2d2a (diff)
downloadobnam2-345c5d822776ef78e594c2365d8bfd39202952e0.tar.gz
refactor: use a struct instead of a tuple
It seems this is more idiomatic in Rust.
Diffstat (limited to 'src/indexedstore.rs')
-rw-r--r--src/indexedstore.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/indexedstore.rs b/src/indexedstore.rs
index 4cc90cc..5a41406 100644
--- a/src/indexedstore.rs
+++ b/src/indexedstore.rs
@@ -2,7 +2,7 @@ use crate::chunk::DataChunk;
use crate::chunkid::ChunkId;
use crate::chunkmeta::ChunkMeta;
use crate::index::Index;
-use crate::store::Store;
+use crate::store::{LoadedChunk, Store};
use std::path::Path;
/// A store for chunks and their metadata.
@@ -31,7 +31,7 @@ impl IndexedStore {
Ok(id)
}
- pub fn load(&self, id: &ChunkId) -> anyhow::Result<(ChunkMeta, DataChunk)> {
+ pub fn load(&self, id: &ChunkId) -> anyhow::Result<LoadedChunk> {
self.store.load(id)
}
@@ -48,8 +48,8 @@ impl IndexedStore {
}
pub fn remove(&mut self, id: &ChunkId) -> anyhow::Result<()> {
- let (meta, _) = self.store.load(id)?;
- self.index.remove("sha256", meta.sha256());
+ let loaded = self.store.load(id)?;
+ self.index.remove("sha256", loaded.meta().sha256());
self.index.remove_generation(id);
self.store.delete(id)?;
Ok(())