Skip to main content

void_core/store/
remote.rs

1//! Remote object store trait
2//!
3//! Abstract interface for fetching and pushing encrypted blobs to/from
4//! a remote content-addressed store. IPFS is the current implementation.
5
6use void_crypto::EncryptedBlob;
7
8use crate::cid::VoidCid;
9use crate::Result;
10
11/// Remote content-addressed storage.
12///
13/// All reads and writes go through typed encrypted blobs.
14/// Implementations handle CID verification internally — callers
15/// receive verified, typed blobs.
16pub trait RemoteStore {
17    /// Fetch a typed encrypted blob by CID.
18    ///
19    /// Implementations must verify the fetched content matches the CID
20    /// before returning.
21    fn fetch<B: EncryptedBlob>(&self, cid: &VoidCid) -> Result<B>;
22
23    /// Push a typed encrypted blob, returning its CID.
24    ///
25    /// Implementations must verify the returned CID matches the blob content.
26    fn push<B: EncryptedBlob>(&self, blob: &B) -> Result<VoidCid>;
27
28    /// Check if a blob exists on the remote.
29    fn exists(&self, cid: &VoidCid) -> Result<bool>;
30
31    /// Pin a blob to prevent remote garbage collection.
32    fn pin(&self, cid: &VoidCid) -> Result<()>;
33}