Trait iroh_bytes::store::Store
source · pub trait Store: ReadableStore + PartialMap {
Show 13 methods
// Required methods
fn import_file(
&self,
data: PathBuf,
mode: ImportMode,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>;
fn import_bytes(
&self,
bytes: Bytes,
format: BlobFormat
) -> BoxFuture<'_, Result<TempTag>>;
fn import_stream(
&self,
data: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>;
fn set_tag(
&self,
name: Tag,
hash: Option<HashAndFormat>
) -> BoxFuture<'_, Result<()>>;
fn create_tag(&self, hash: HashAndFormat) -> BoxFuture<'_, Result<Tag>>;
fn temp_tag(&self, value: HashAndFormat) -> TempTag;
fn clear_live(&self);
fn add_live(&self, live: impl IntoIterator<Item = Hash>);
fn is_live(&self, hash: &Hash) -> bool;
fn delete(&self, hash: &Hash) -> BoxFuture<'_, Result<()>>;
// Provided methods
fn import_reader(
&self,
data: impl AsyncRead + Send + Unpin + 'static,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>> { ... }
fn gc_mark<'a>(
&'a self,
extra_roots: impl IntoIterator<Item = Result<HashAndFormat>> + 'a
) -> LocalBoxStream<'a, GcMarkEvent> { ... }
fn gc_sweep(&self) -> LocalBoxStream<'_, GcSweepEvent> { ... }
}Expand description
The mutable part of a BaoDb
Required Methods§
sourcefn import_file(
&self,
data: PathBuf,
mode: ImportMode,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>
fn import_file( &self, data: PathBuf, mode: ImportMode, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> BoxFuture<'_, Result<(TempTag, u64)>>
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.
sourcefn import_bytes(
&self,
bytes: Bytes,
format: BlobFormat
) -> BoxFuture<'_, Result<TempTag>>
fn import_bytes( &self, bytes: Bytes, format: BlobFormat ) -> BoxFuture<'_, Result<TempTag>>
Import data from memory.
It is a special case of import that does not use the file system.
sourcefn import_stream(
&self,
data: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>
fn import_stream( &self, data: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> BoxFuture<'_, Result<(TempTag, u64)>>
Import data from a stream of bytes.
sourcefn set_tag(
&self,
name: Tag,
hash: Option<HashAndFormat>
) -> BoxFuture<'_, Result<()>>
fn set_tag( &self, name: Tag, hash: Option<HashAndFormat> ) -> BoxFuture<'_, Result<()>>
Set a tag
sourcefn create_tag(&self, hash: HashAndFormat) -> BoxFuture<'_, Result<Tag>>
fn create_tag(&self, hash: HashAndFormat) -> BoxFuture<'_, Result<Tag>>
Create a new tag
sourcefn temp_tag(&self, value: HashAndFormat) -> TempTag
fn temp_tag(&self, value: HashAndFormat) -> TempTag
Create a temporary pin for this store
sourcefn clear_live(&self)
fn clear_live(&self)
Clear the live set.
sourcefn add_live(&self, live: impl IntoIterator<Item = Hash>)
fn add_live(&self, live: impl IntoIterator<Item = Hash>)
Add the given hashes to the live set.
This is used by the gc mark phase to mark roots as live.
Provided Methods§
sourcefn import_reader(
&self,
data: impl AsyncRead + Send + Unpin + 'static,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>
fn import_reader( &self, data: impl AsyncRead + Send + Unpin + 'static, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> BoxFuture<'_, Result<(TempTag, u64)>>
Import data from an async byte reader.
sourcefn gc_mark<'a>(
&'a self,
extra_roots: impl IntoIterator<Item = Result<HashAndFormat>> + 'a
) -> LocalBoxStream<'a, GcMarkEvent>
fn gc_mark<'a>( &'a self, extra_roots: impl IntoIterator<Item = Result<HashAndFormat>> + 'a ) -> LocalBoxStream<'a, GcMarkEvent>
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.
sourcefn gc_sweep(&self) -> LocalBoxStream<'_, GcSweepEvent>
fn gc_sweep(&self) -> LocalBoxStream<'_, GcSweepEvent>
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.