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_start(&self) -> impl Future<Output = Result<()>> + Send; fn delete( &self, hashes: Vec<Hash>, ) -> impl Future<Output = Result<()>> + Send; fn shutdown(&self) -> impl Future<Output = ()> + 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 gc_mark( &self, live: &mut BTreeSet<Hash>, ) -> impl Stream<Item = GcMarkEvent> + Unpin { ... } fn gc_sweep( &self, live: &BTreeSet<Hash>, ) -> impl Stream<Item = GcSweepEvent> + Unpin { ... } 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_start(&self) -> impl Future<Output = Result<()>> + Send

Notify the store that a new gc phase is about to start.

This should not fail unless the store is shut down or otherwise in a bad state. The gc task will shut itself down if this fails.

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.

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 gc_mark( &self, live: &mut BTreeSet<Hash>, ) -> impl Stream<Item = GcMarkEvent> + Unpin

Traverse all roots recursively and mark them as live.

Poll this stream to completion to perform a full gc mark phase.

Not polling this stream to completion is dangerous, since it might lead to some live data being missed.

The implementation of this method should do the minimum amount of work to determine the live set. Actual deletion of garbage should be done in the gc_sweep phase.

source

fn gc_sweep( &self, live: &BTreeSet<Hash>, ) -> impl Stream<Item = GcSweepEvent> + Unpin

Remove all blobs that are not marked as live.

Poll this stream to completion to perform a full gc sweep. Not polling this stream to completion just means that some garbage will remain in the database.

Sweeping might take long, but it can safely be done in the background.

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