From df443569e9dbe855bbbc1f2490aaa46f6e2b07d4 Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Thu, 28 Nov 2024 17:02:39 +0200 Subject: [PATCH 1/2] Add Blobs::builder and use it from Blobs::memory and Blobs::persistent --- src/net_protocol.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/net_protocol.rs b/src/net_protocol.rs index 31b92386f..83d4c72ab 100644 --- a/src/net_protocol.rs +++ b/src/net_protocol.rs @@ -153,27 +153,30 @@ impl Builder { } } -impl Blobs { - /// Create a new memory-backed Blobs protocol handler. - pub fn memory() -> Builder { +impl Blobs { + /// Create a new Blobs protocol handler builder, given a store. + pub fn builder(store: S) -> Builder { Builder { - store: crate::store::mem::Store::new(), + store, events: None, gc_config: None, } } } +impl Blobs { + /// Create a new memory-backed Blobs protocol handler. + pub fn memory() -> Builder { + Self::builder(crate::store::mem::Store::new()) + } +} + impl Blobs { /// Load a persistent Blobs protocol handler from a path. pub async fn persistent( path: impl AsRef, ) -> anyhow::Result> { - Ok(Builder { - store: crate::store::fs::Store::load(path).await?, - events: None, - gc_config: None, - }) + Ok(Self::builder(crate::store::fs::Store::load(path).await?)) } } From 93d0db26dd213413cc7eced822bb1f63879f9d6d Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Thu, 28 Nov 2024 17:24:39 +0200 Subject: [PATCH 2/2] clippy --- src/store/fs/tables.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/fs/tables.rs b/src/store/fs/tables.rs index afbf8b66f..d49dd42e7 100644 --- a/src/store/fs/tables.rs +++ b/src/store/fs/tables.rs @@ -83,8 +83,8 @@ pub(super) struct ReadOnlyTables { pub inline_outboard: redb::ReadOnlyTable, } -impl<'txn> ReadOnlyTables { - pub fn new(tx: &'txn redb::ReadTransaction) -> std::result::Result { +impl ReadOnlyTables { + pub fn new(tx: &redb::ReadTransaction) -> std::result::Result { Ok(Self { blobs: tx.open_table(BLOBS_TABLE)?, tags: tx.open_table(TAGS_TABLE)?,