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 legacy_fs(path: &Path) -> Result<Self, BlobsStoreError>
pub async fn legacy_fs(path: &Path) -> Result<Self, BlobsStoreError>
Legacy: load from filesystem using iroh’s FsStore directly.
Sourcepub async fn legacy_memory() -> Result<Self, BlobsStoreError>
pub async fn legacy_memory() -> Result<Self, BlobsStoreError>
Legacy: in-memory using iroh’s MemStore directly.
Sourcepub async fn fs(data_dir: &Path) -> Result<Self, BlobsStoreError>
pub async fn fs(data_dir: &Path) -> Result<Self, BlobsStoreError>
Local filesystem via ObjectStore (SQLite + local object storage).
Sourcepub async fn memory() -> Result<Self, BlobsStoreError>
pub async fn memory() -> Result<Self, BlobsStoreError>
In-memory via ObjectStore.
Sourcepub async fn s3(
db_path: &Path,
endpoint: &str,
access_key: &str,
secret_key: &str,
bucket: &str,
region: Option<&str>,
) -> Result<Self, BlobsStoreError>
pub async fn s3( db_path: &Path, endpoint: &str, access_key: &str, secret_key: &str, bucket: &str, region: Option<&str>, ) -> Result<Self, BlobsStoreError>
S3-backed via ObjectStore.
Sourcepub fn from_store(store: Store) -> Self
pub fn from_store(store: Store) -> Self
Wrap an existing iroh-blobs Store (kept for flexibility).
Sourcepub async fn get_cbor<T: BlockEncoded<DagCborCodec>>(
&self,
hash: &Hash,
) -> Result<T, BlobsStoreError>
pub async fn get_cbor<T: BlockEncoded<DagCborCodec>>( &self, hash: &Hash, ) -> Result<T, BlobsStoreError>
Get a blob as a block encoded
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<PublicKey>,
endpoint: &Endpoint,
) -> Result<(), BlobsStoreError>
pub async fn download_hash( &self, hash: Hash, peer_ids: Vec<PublicKey>, 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<PublicKey>,
endpoint: &Endpoint,
) -> Result<(), BlobsStoreError>
pub async fn download_hash_list( &self, hash_list_hash: Hash, peer_ids: Vec<PublicKey>, 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 moreSource§impl Debug for BlobsStore
impl Debug for BlobsStore
Auto Trait Implementations§
impl Freeze for BlobsStore
impl !RefUnwindSafe for BlobsStore
impl Send for BlobsStore
impl Sync for BlobsStore
impl Unpin for BlobsStore
impl !UnwindSafe for BlobsStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more