Trait iroh_blobs::store::Store
source · pub trait Store: ReadableStore + MapMut + Debug {
// 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 validate(
&self,
repair: bool,
tx: BoxedProgressSender<ValidateProgress>
) -> impl Future<Output = Result<()>> + Send { ... }
}
Expand description
The mutable part of a Bao store.
Required Methods§
sourcefn import_file(
&self,
data: PathBuf,
mode: ImportMode,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> impl Future<Output = Result<(TempTag, u64)>> + Send
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.
sourcefn import_bytes(
&self,
bytes: Bytes,
format: BlobFormat
) -> impl Future<Output = Result<TempTag>> + Send
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.
sourcefn 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 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.
sourcefn set_tag(
&self,
name: Tag,
hash: Option<HashAndFormat>
) -> impl Future<Output = Result<()>> + Send
fn set_tag( &self, name: Tag, hash: Option<HashAndFormat> ) -> impl Future<Output = Result<()>> + Send
Set a tag
sourcefn create_tag(
&self,
hash: HashAndFormat
) -> impl Future<Output = Result<Tag>> + Send
fn create_tag( &self, hash: HashAndFormat ) -> impl Future<Output = Result<Tag>> + Send
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 gc_run<G, Gut>(
&self,
config: GcConfig,
protected_cb: G
) -> impl Future<Output = ()>
fn gc_run<G, Gut>( &self, config: GcConfig, protected_cb: G ) -> impl Future<Output = ()>
Start the GC loop
The gc task will shut down, when dropping the returned future.
Provided Methods§
sourcefn 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_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.
sourcefn validate(
&self,
repair: bool,
tx: BoxedProgressSender<ValidateProgress>
) -> impl Future<Output = Result<()>> + Send
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.