summaryrefslogtreecommitdiff
path: root/src/store.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/store.rs')
-rw-r--r--src/store.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/store.rs b/src/store.rs
index a415d7a..123b9fa 100644
--- a/src/store.rs
+++ b/src/store.rs
@@ -61,11 +61,12 @@ impl Store {
}
/// Load a chunk from a store.
- pub fn load(&self, id: &ChunkId) -> anyhow::Result<(ChunkMeta, DataChunk)> {
+ pub fn load(&self, id: &ChunkId) -> anyhow::Result<LoadedChunk> {
let (_, _, dataname) = &self.filenames(id);
let meta = self.load_meta(id)?;
let data = std::fs::read(&dataname)?;
- Ok((meta, DataChunk::new(data)))
+ let data = DataChunk::new(data);
+ Ok(LoadedChunk { meta, data })
}
/// Delete a chunk from a store.
@@ -76,3 +77,22 @@ impl Store {
Ok(())
}
}
+
+pub struct LoadedChunk {
+ meta: ChunkMeta,
+ data: DataChunk,
+}
+
+impl LoadedChunk {
+ pub fn new(meta: ChunkMeta, data: DataChunk) -> Self {
+ Self { meta, data }
+ }
+
+ pub fn meta(&self) -> &ChunkMeta {
+ &self.meta
+ }
+
+ pub fn data(&self) -> &DataChunk {
+ &self.data
+ }
+}