summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-10-28 12:52:20 +0000
committerLars Wirzenius <liw@liw.fi>2022-10-28 12:52:20 +0000
commitd74b1d2503ebd54ca160cde0c8aa049c53dfcaf9 (patch)
tree9e0aaf358cc51cdff85618da43f85a101ad4b953
parent5a342d99d2136d1cd1fa227e9125d3f3f5affe9c (diff)
parent002d30d55b949bf9a7023b0c3acc2bad184f07ad (diff)
downloadobnam2-d74b1d2503ebd54ca160cde0c8aa049c53dfcaf9.tar.gz
Merge branch 'liw/tidy-up' into 'main'
chore: drop IndexedStore, which wasn't used anywhere, anymore See merge request obnam/obnam!241
-rw-r--r--src/indexedstore.rs77
-rw-r--r--src/lib.rs1
2 files changed, 0 insertions, 78 deletions
diff --git a/src/indexedstore.rs b/src/indexedstore.rs
deleted file mode 100644
index 15b5a22..0000000
--- a/src/indexedstore.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-//! An indexed, on-disk store for chunks on the server.
-
-use crate::chunk::{DataChunk, GenerationChunkError};
-use crate::chunkid::ChunkId;
-use crate::chunkmeta::ChunkMeta;
-use crate::index::{Index, IndexError};
-use crate::store::{Store, StoreError};
-use std::path::Path;
-
-/// A store for chunks and their metadata.
-///
-/// This combines Store and Index into one interface to make it easier
-/// to handle the server side storage of chunks.
-pub struct IndexedStore {
- store: Store,
- index: Index,
-}
-
-/// All the errors that may be returned for `IndexStore`.
-#[derive(Debug, thiserror::Error)]
-pub enum IndexedError {
- /// An error from Index.
- #[error(transparent)]
- IndexError(#[from] IndexError),
-
- /// Error regarding generation chunks.
- #[error(transparent)]
- GenerationChunkError(#[from] GenerationChunkError),
-
- /// An error from Store.
- #[error(transparent)]
- SqlError(#[from] StoreError),
-}
-
-impl IndexedStore {
- /// Create a new indexed store.
- pub fn new(dirname: &Path) -> Result<Self, IndexedError> {
- let store = Store::new(dirname);
- let index = Index::new(dirname)?;
- Ok(Self { store, index })
- }
-
- /// Save a chunk in the store.
- pub fn save(&mut self, chunk: &DataChunk) -> Result<ChunkId, IndexedError> {
- 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) -> Result<(), IndexedError> {
- self.index.insert_meta(id.clone(), meta.clone())?;
- Ok(())
- }
-
- /// Get a chunk from the store, given its id.
- pub fn load(&self, id: &ChunkId) -> Result<(DataChunk, ChunkMeta), IndexedError> {
- Ok((self.store.load(id)?, self.load_meta(id)?))
- }
-
- /// Get a chunk's metadata form the store, given its id.
- pub fn load_meta(&self, id: &ChunkId) -> Result<ChunkMeta, IndexedError> {
- Ok(self.index.get_meta(id)?)
- }
-
- /// Find chunks with a client-assigned label.
- pub fn find_by_label(&self, label: &str) -> Result<Vec<ChunkId>, IndexedError> {
- Ok(self.index.find_by_label(label)?)
- }
-
- /// Remove a chunk from the store.
- pub fn remove(&mut self, id: &ChunkId) -> Result<(), IndexedError> {
- self.index.remove_meta(id)?;
- self.store.delete(id)?;
- Ok(())
- }
-}
diff --git a/src/lib.rs b/src/lib.rs
index a54c5ff..8894966 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,7 +28,6 @@ pub mod generation;
pub mod genlist;
pub mod genmeta;
pub mod index;
-pub mod indexedstore;
pub mod label;
pub mod passwords;
pub mod performance;