pub struct BlobsStore {
pub inner: Arc<BlobsProtocol>,
}
Expand description
Client over a local iroh-blob store. Exposes an iroh-blobs peer over the endpoint. Router must handle the iroh-blobs APLN Also acts as our main BlockStore implemenetation for bucket, node, and data storage and retrieval
Fields§
§inner: Arc<BlobsProtocol>
Implementations§
Source§impl BlobsStore
impl BlobsStore
Sourcepub async fn load(path: &Path) -> Result<Self, BlobsStoreError>
pub async fn load(path: &Path) -> Result<Self, BlobsStoreError>
Load a blob store from the given path, using the given endpoint. Endpoint exposes a network interface for blob operations with peers.
§Arguments
path
- Path to the blob store on diskendpoint
- Endpoint to use for network operations Exposes a peer for the private key used to initiate the endpoint.
Sourcepub async fn get_reader(&self, hash: Hash) -> Result<Reader, BlobsStoreError>
pub async fn get_reader(&self, hash: Hash) -> Result<Reader, BlobsStoreError>
Get a blob from the store as a reader
Sourcepub async fn put_stream(
&self,
stream: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static + Sync,
) -> Result<Hash, BlobsStoreError>
pub async fn put_stream( &self, stream: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static + Sync, ) -> Result<Hash, BlobsStoreError>
Store a stream of bytes as a blob
Sourcepub async fn put(&self, data: Vec<u8>) -> Result<Hash, BlobsStoreError>
pub async fn put(&self, data: Vec<u8>) -> Result<Hash, BlobsStoreError>
Store a vec of bytes as a blob
Sourcepub async fn download_hash(
&self,
hash: Hash,
peer_ids: Vec<NodeId>,
endpoint: &Endpoint,
) -> Result<(), BlobsStoreError>
pub async fn download_hash( &self, hash: Hash, peer_ids: Vec<NodeId>, endpoint: &Endpoint, ) -> Result<(), BlobsStoreError>
Download a single hash from peers
This checks if the hash exists locally first, then downloads if needed. Uses the Downloader API with Shuffled content discovery.
Sourcepub async fn download_hash_list(
&self,
hash_list_hash: Hash,
peer_ids: Vec<NodeId>,
endpoint: &Endpoint,
) -> Result<(), BlobsStoreError>
pub async fn download_hash_list( &self, hash_list_hash: Hash, peer_ids: Vec<NodeId>, endpoint: &Endpoint, ) -> Result<(), BlobsStoreError>
Download a hash list (pinset) and all referenced hashes
This first downloads the hash list blob, reads the list of hashes, then downloads each referenced hash.
Sourcepub async fn create_hash_list<I>(
&self,
hashes: I,
) -> Result<Hash, BlobsStoreError>where
I: IntoIterator<Item = Hash>,
pub async fn create_hash_list<I>(
&self,
hashes: I,
) -> Result<Hash, BlobsStoreError>where
I: IntoIterator<Item = Hash>,
Create a simple blob containing a sequence of hashes Each hash is 32 bytes, stored consecutively Returns the hash of the blob containing all the hashes
Sourcepub async fn read_hash_list(
&self,
list_hash: Hash,
) -> Result<Vec<Hash>, BlobsStoreError>
pub async fn read_hash_list( &self, list_hash: Hash, ) -> Result<Vec<Hash>, BlobsStoreError>
Read all hashes from a hash list blob Returns a Vec of all hashes in the list
Trait Implementations§
Source§impl Clone for BlobsStore
impl Clone for BlobsStore
Source§fn clone(&self) -> BlobsStore
fn clone(&self) -> BlobsStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more