void_core/store/remote.rs
1//! Remote object store trait — object-safe for `dyn RemoteStore`.
2//!
3//! Deals in raw bytes at the network boundary. Typed blob wrapping
4//! happens in the caller (`VoidContext::fetch_object`, pipeline helpers).
5//!
6//! Implementations must verify content matches CID on fetch.
7
8use crate::cid::VoidCid;
9use crate::Result;
10
11/// Remote content-addressed storage.
12///
13/// Object-safe — can be used as `dyn RemoteStore` and `Arc<dyn RemoteStore>`.
14/// All operations use raw bytes. Typed `EncryptedBlob` wrapping happens
15/// in the callers, not here.
16pub trait RemoteStore: Send + Sync {
17 /// Fetch raw bytes by CID.
18 ///
19 /// Implementations must verify the fetched content hash matches the CID.
20 fn fetch_raw(&self, cid: &VoidCid) -> Result<Vec<u8>>;
21
22 /// Push raw bytes, returning the content CID.
23 ///
24 /// Implementations must verify the returned CID matches the pushed content.
25 fn push_raw(&self, data: &[u8]) -> Result<VoidCid>;
26
27 /// Check if a blob exists on the remote.
28 fn exists(&self, cid: &VoidCid) -> Result<bool>;
29
30 /// Pin a blob to prevent remote garbage collection.
31 fn pin(&self, cid: &VoidCid) -> Result<()>;
32}