pub struct BlobStore { /* private fields */ }Implementations§
Source§impl BlobStore
impl BlobStore
pub fn new(protocol: &BlobsProtocol) -> Self
pub fn new_with_address_lookup( protocol: &BlobsProtocol, address_lookup: MemoryLookup, ) -> Self
pub const fn inner(&self) -> &BlobApi
Sourcepub fn add_endpoint_addr(&self, addr: EndpointAddr)
pub fn add_endpoint_addr(&self, addr: EndpointAddr)
Register a peer’s known addresses so later connections (such as blob downloads that only carry the peer’s node id) can resolve the peer without LAN discovery.
Sourcepub fn reader(&self, hash: impl Into<Hash>) -> BlobReader
pub fn reader(&self, hash: impl Into<Hash>) -> BlobReader
Create a reader for the given hash.
The reader implements tokio::io::AsyncRead and tokio::io::AsyncSeek,
allowing O(1)-memory streaming to any sink.
Sourcepub async fn add_bytes(&self, data: impl AsRef<[u8]>) -> Result<Hash>
pub async fn add_bytes(&self, data: impl AsRef<[u8]>) -> Result<Hash>
§Errors
Returns an error if the blob fails to be added to the store.
Sourcepub async fn add_file(&self, path: impl AsRef<Path>) -> Result<Hash>
pub async fn add_file(&self, path: impl AsRef<Path>) -> Result<Hash>
§Errors
Returns an error if the file fails to be read or added to the store.
Sourcepub async fn add_file_ref(&self, path: impl AsRef<Path>) -> Result<Hash>
pub async fn add_file_ref(&self, path: impl AsRef<Path>) -> Result<Hash>
Add a file using a reference to its original path instead of copying its contents into the blob store.
The source file must remain available and unchanged for as long as the blob store may need to read this blob.
§Errors
Returns an error if the file fails to be read or added to the store.
Sourcepub async fn export_to_path(
&self,
hash: Hash,
destination: impl AsRef<Path>,
) -> Result<u64>
pub async fn export_to_path( &self, hash: Hash, destination: impl AsRef<Path>, ) -> Result<u64>
Export a complete blob to a temporary or caller-managed path.
Uses ExportMode::Copy — the blob stays in the store and a copy
(or CoW reflink) is written to destination.
§Errors
Returns an error if the blob cannot be read or written.
Sourcepub async fn export_to_path_with_mode(
&self,
hash: Hash,
destination: impl AsRef<Path>,
mode: ExportMode,
) -> Result<u64>
pub async fn export_to_path_with_mode( &self, hash: Hash, destination: impl AsRef<Path>, mode: ExportMode, ) -> Result<u64>
Export a complete blob with a specific ExportMode.
ExportMode::TryReference moves the blob’s internal file to
destination and updates the store to track it externally,
avoiding a copy. ExportMode::Copy leaves the blob in the store
and writes a copy (or CoW reflink) to destination.
§Errors
Returns an error if the blob cannot be read or written.
Sourcepub async fn has(&self, hash: Hash) -> Result<bool>
pub async fn has(&self, hash: Hash) -> Result<bool>
§Errors
Returns an error if the store cannot be queried.
Sourcepub async fn stat(&self, hash: Hash) -> Result<BlobStatus>
pub async fn stat(&self, hash: Hash) -> Result<BlobStatus>
Get metadata (size) for a blob.
§Errors
Returns an error if the blob is not found or the store cannot be queried.
Sourcepub async fn get(&self, hash: Hash) -> Result<Bytes>
pub async fn get(&self, hash: Hash) -> Result<Bytes>
§Errors
Returns an error if the blob cannot be found or read.
pub fn ticket(&self, endpoint: &Endpoint, hash: Hash) -> BlobTicket
pub fn ticket_for_addr(&self, addr: EndpointAddr, hash: Hash) -> BlobTicket
Sourcepub async fn pin(&self, name: impl AsRef<str>, hash: Hash) -> Result<()>
pub async fn pin(&self, name: impl AsRef<str>, hash: Hash) -> Result<()>
Pin a blob with a durable named tag so garbage collection cannot remove it.
§Errors
Returns an error if the tag cannot be written.
Sourcepub async fn is_pinned(&self, name: impl AsRef<str>, hash: Hash) -> Result<bool>
pub async fn is_pinned(&self, name: impl AsRef<str>, hash: Hash) -> Result<bool>
§Errors
Returns an error if the pin cannot be queried.
Sourcepub async fn list_hashes(&self) -> Result<Vec<Hash>>
pub async fn list_hashes(&self) -> Result<Vec<Hash>>
List all complete blobs currently in the store.
§Errors
Returns an error if the store cannot be queried.
Sourcepub async fn list_pins(
&self,
prefix: impl AsRef<[u8]>,
) -> Result<Vec<(String, Hash)>>
pub async fn list_pins( &self, prefix: impl AsRef<[u8]>, ) -> Result<Vec<(String, Hash)>>
List named pins whose names start with prefix.
§Errors
Returns an error if the store cannot be queried.
Sourcepub async fn fetch(
&self,
endpoint: &Endpoint,
ticket: &BlobTicket,
) -> Result<()>
pub async fn fetch( &self, endpoint: &Endpoint, ticket: &BlobTicket, ) -> Result<()>
§Errors
Returns an error if the blob cannot be fetched from the remote endpoint.
Sourcepub async fn fetch_and_pin(
&self,
endpoint: &Endpoint,
content_hash: Hash,
tickets: &[BlobTicket],
) -> Result<()>
pub async fn fetch_and_pin( &self, endpoint: &Endpoint, content_hash: Hash, tickets: &[BlobTicket], ) -> Result<()>
Fetch a blob through the first working provider ticket and pin it, skipping the fetch when the blob is already present locally.
§Errors
Returns an error if the blob cannot be fetched through any ticket.
Sourcepub async fn force_fetch(
&self,
endpoint: &Endpoint,
ticket: &BlobTicket,
) -> Result<()>
pub async fn force_fetch( &self, endpoint: &Endpoint, ticket: &BlobTicket, ) -> Result<()>
Force-fetch a blob from a remote peer, re-downloading even if the blob
is already present locally. Uses iroh-blobs’ low-level execute_get
API which does not check local availability.
§Errors
Returns an error if the connection or download fails.
Sourcepub async fn force_fetch_from_peer(
&self,
endpoint: &Endpoint,
peer: &EndpointAddr,
hash: Hash,
) -> Result<()>
pub async fn force_fetch_from_peer( &self, endpoint: &Endpoint, peer: &EndpointAddr, hash: Hash, ) -> Result<()>
Force-fetch a blob from a known peer, connecting by its discovered address (which may include a relay or custom transport address).
§Errors
Returns an error if the connection or download fails.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BlobStore
impl !UnwindSafe for BlobStore
impl Freeze for BlobStore
impl Send for BlobStore
impl Sync for BlobStore
impl Unpin for BlobStore
impl UnsafeUnpin for BlobStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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