Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/net_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,30 @@ impl<S: crate::store::Store> Builder<S> {
}
}

impl Blobs<crate::store::mem::Store> {
/// Create a new memory-backed Blobs protocol handler.
pub fn memory() -> Builder<crate::store::mem::Store> {
impl<S> Blobs<S> {
/// Create a new Blobs protocol handler builder, given a store.
pub fn builder(store: S) -> Builder<S> {
Builder {
store: crate::store::mem::Store::new(),
store,
events: None,
gc_config: None,
}
}
}

impl Blobs<crate::store::mem::Store> {
/// Create a new memory-backed Blobs protocol handler.
pub fn memory() -> Builder<crate::store::mem::Store> {
Self::builder(crate::store::mem::Store::new())
}
}

impl Blobs<crate::store::fs::Store> {
/// Load a persistent Blobs protocol handler from a path.
pub async fn persistent(
path: impl AsRef<std::path::Path>,
) -> anyhow::Result<Builder<crate::store::fs::Store>> {
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?))
}
}

Expand Down
Loading