pub struct Store { /* private fields */ }
Expand description
The main entry point for the store API.
Implementations§
Source§impl Store
impl Store
The tags API.
Sourcepub fn downloader(&self, endpoint: &Endpoint) -> Downloader
pub fn downloader(&self, endpoint: &Endpoint) -> Downloader
Create a downloader for more complex downloads.
Unlike the other APIs, this creates an object that has internal state, so don’t create it ad hoc but store it somewhere if you need it multiple times.
Sourcepub fn connect(endpoint: Endpoint, addr: SocketAddr) -> Self
pub fn connect(endpoint: Endpoint, addr: SocketAddr) -> Self
Connect to a remote store as a rpc client.
Sourcepub async fn listen(self, endpoint: Endpoint)
pub async fn listen(self, endpoint: Endpoint)
Listen on a quinn endpoint for incoming rpc connections.
pub async fn sync_db(&self) -> RequestResult<()>
pub async fn shutdown(&self) -> Result<()>
Methods from Deref<Target = Blobs>§
pub async fn batch(&self) -> Result<Batch<'_>>
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
]
and therefore can be used to read the blob’s content.
Any access to parts of the blob that are not present will result in an error.
Example:
use iroh_blobs::{store::mem::MemStore, api::blobs::Blobs};
use tokio::io::AsyncReadExt;
let store = MemStore::new();
let tag = store.add_slice(b"Hello, world!").await?;
let mut reader = store.reader(tag.hash);
let mut buf = String::new();
reader.read_to_string(&mut buf).await?;
assert_eq!(buf, "Hello, world!");
}
Sourcepub fn reader_with_opts(&self, options: ReaderOptions) -> BlobReader
pub fn reader_with_opts(&self, options: ReaderOptions) -> BlobReader
Create a reader for the given options. The reader implements [tokio::io::AsyncRead
] and [tokio::io::AsyncSeek
]
and therefore can be used to read the blob’s content.
Any access to parts of the blob that are not present will result in an error.
pub fn add_slice(&self, data: impl AsRef<[u8]>) -> AddProgress<'_>
pub fn add_bytes(&self, data: impl Into<Bytes>) -> AddProgress<'_>
pub fn add_bytes_with_opts( &self, options: impl Into<AddBytesOptions>, ) -> AddProgress<'_>
pub fn add_path_with_opts( &self, options: impl Into<AddPathOptions>, ) -> AddProgress<'_>
pub fn add_path(&self, path: impl AsRef<Path>) -> AddProgress<'_>
pub async fn add_stream( &self, data: impl Stream<Item = Result<Bytes>> + Send + Sync + 'static, ) -> AddProgress<'_>
pub fn export_ranges( &self, hash: impl Into<Hash>, ranges: impl Into<RangeSet2<u64>>, ) -> ExportRangesProgress
pub fn export_ranges_with_opts( &self, options: ExportRangesOptions, ) -> ExportRangesProgress
pub fn export_bao_with_opts( &self, options: ExportBaoOptions, local_update_cap: usize, ) -> ExportBaoProgress
pub fn export_bao( &self, hash: impl Into<Hash>, ranges: impl Into<ChunkRanges>, ) -> ExportBaoProgress
Sourcepub async fn export_chunk(
&self,
hash: impl Into<Hash>,
offset: u64,
) -> ExportBaoResult<Leaf>
pub async fn export_chunk( &self, hash: impl Into<Hash>, offset: u64, ) -> ExportBaoResult<Leaf>
Export a single chunk from the given hash, at the given offset.
Sourcepub async fn get_bytes(&self, hash: impl Into<Hash>) -> ExportBaoResult<Bytes>
pub async fn get_bytes(&self, hash: impl Into<Hash>) -> ExportBaoResult<Bytes>
Get the entire blob into a Bytes
This will run out of memory when called for very large blobs, so be careful!
Sourcepub fn observe(&self, hash: impl Into<Hash>) -> ObserveProgress
pub fn observe(&self, hash: impl Into<Hash>) -> ObserveProgress
Observe the bitfield of the given hash.