Trait iroh_blobs::store::Store

source ·
pub trait Store: ReadableStore + MapMut + Debug {
Show 13 methods // Required methods fn import_file( &self, data: PathBuf, mode: ImportMode, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send; fn import_bytes( &self, bytes: Bytes, format: BlobFormat ) -> impl Future<Output = Result<TempTag>> + Send; fn import_stream( &self, data: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send; fn set_tag( &self, name: Tag, hash: Option<HashAndFormat> ) -> impl Future<Output = Result<()>> + Send; fn create_tag( &self, hash: HashAndFormat ) -> impl Future<Output = Result<Tag>> + Send; fn temp_tag(&self, value: HashAndFormat) -> TempTag; fn gc_run<G, Gut>( &self, config: GcConfig, protected_cb: G ) -> impl Future<Output = ()> where G: Fn() -> Gut, Gut: Future<Output = BTreeSet<Hash>> + Send; fn delete( &self, hashes: Vec<Hash> ) -> impl Future<Output = Result<()>> + Send; fn shutdown(&self) -> impl Future<Output = ()> + Send; fn sync(&self) -> impl Future<Output = Result<()>> + Send; // Provided methods fn import_reader( &self, data: impl AsyncRead + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send { ... } fn import_verifiable_stream<'a>( &'a self, hash: Hash, total_size: u64, offset: u64, reader: impl AsyncStreamReader + 'a ) -> impl Future<Output = Result<()>> + 'a { ... } fn validate( &self, repair: bool, tx: BoxedProgressSender<ValidateProgress> ) -> impl Future<Output = Result<()>> + Send { ... }
}
Expand description

The mutable part of a Bao store.

Required Methods§

source

fn import_file( &self, data: PathBuf, mode: ImportMode, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send

This trait method imports a file from a local path.

data is the path to the file. mode is a hint how the file should be imported. progress is a sender that provides a way for the importer to send progress messages when importing large files. This also serves as a way to cancel the import. If the consumer of the progress messages is dropped, subsequent attempts to send progress will fail.

Returns the hash of the imported file. The reason to have this method is that some database implementations might be able to import a file without copying it.

source

fn import_bytes( &self, bytes: Bytes, format: BlobFormat ) -> impl Future<Output = Result<TempTag>> + Send

Import data from memory.

It is a special case of import that does not use the file system.

source

fn import_stream( &self, data: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send

Import data from a stream of bytes.

source

fn set_tag( &self, name: Tag, hash: Option<HashAndFormat> ) -> impl Future<Output = Result<()>> + Send

Set a tag

source

fn create_tag( &self, hash: HashAndFormat ) -> impl Future<Output = Result<Tag>> + Send

Create a new tag

source

fn temp_tag(&self, value: HashAndFormat) -> TempTag

Create a temporary pin for this store

source

fn gc_run<G, Gut>( &self, config: GcConfig, protected_cb: G ) -> impl Future<Output = ()>
where G: Fn() -> Gut, Gut: Future<Output = BTreeSet<Hash>> + Send,

Start the GC loop

The gc task will shut down, when dropping the returned future.

source

fn delete(&self, hashes: Vec<Hash>) -> impl Future<Output = Result<()>> + Send

physically delete the given hashes from the store.

source

fn shutdown(&self) -> impl Future<Output = ()> + Send

Shutdown the store.

source

fn sync(&self) -> impl Future<Output = Result<()>> + Send

Sync the store.

Provided Methods§

source

fn import_reader( &self, data: impl AsyncRead + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> impl Future<Output = Result<(TempTag, u64)>> + Send

Import data from an async byte reader.

source

fn import_verifiable_stream<'a>( &'a self, hash: Hash, total_size: u64, offset: u64, reader: impl AsyncStreamReader + 'a ) -> impl Future<Output = Result<()>> + 'a

Import a blob from a verified stream, as emitted by MapEntry::write_verifiable_stream;

total_size is the total size of the blob as reported by the remote. offset is the byte offset in the blob where the stream starts. It will be rounded to the next chunk group.

source

fn validate( &self, repair: bool, tx: BoxedProgressSender<ValidateProgress> ) -> impl Future<Output = Result<()>> + Send

Validate the database

This will check that the file and outboard content is correct for all complete entries, and output valid ranges for all partial entries.

It will not check the internal consistency of the database.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Store for iroh_blobs::store::fs::Store

source§

impl Store for iroh_blobs::store::mem::Store

source§

impl Store for iroh_blobs::store::readonly_mem::Store