Struct iroh_blobs::store::readonly_mem::Store
source · pub struct Store(/* private fields */);
Expand description
A readonly in memory database for iroh-blobs.
This is basically just a HashMap, so it does not allow for any modifications unless you have a mutable reference to it.
It is therefore useful mostly for testing and sharing static data.
Implementations§
source§impl Store
impl Store
sourcepub fn new(
entries: impl IntoIterator<Item = (impl Into<String>, impl AsRef<[u8]>)>
) -> (Self, BTreeMap<String, Hash>)
pub fn new( entries: impl IntoIterator<Item = (impl Into<String>, impl AsRef<[u8]>)> ) -> (Self, BTreeMap<String, Hash>)
Create a new Store from a sequence of entries.
Returns the database and a map of names to computed blake3 hashes. In case of duplicate names, the last entry is used.
sourcepub fn insert(&mut self, data: impl AsRef<[u8]>) -> Hash
pub fn insert(&mut self, data: impl AsRef<[u8]>) -> Hash
Insert a new entry into the database, and return the hash of the entry.
If the database was shared before, this will make a copy.
sourcepub fn insert_many(
&mut self,
items: impl IntoIterator<Item = impl AsRef<[u8]>>
) -> Option<Hash>
pub fn insert_many( &mut self, items: impl IntoIterator<Item = impl AsRef<[u8]>> ) -> Option<Hash>
Insert multiple entries into the database, and return the hash of the last entry.
sourcepub fn get_content(&self, hash: &Hash) -> Option<Bytes>
pub fn get_content(&self, hash: &Hash) -> Option<Bytes>
Get the bytes associated with a hash, if they exist.
Trait Implementations§
source§impl<K, V> FromIterator<(K, V)> for Store
impl<K, V> FromIterator<(K, V)> for Store
source§impl MapMut for Store
impl MapMut for Store
source§async fn get_mut(&self, hash: &Hash) -> Result<Option<Self::EntryMut>>
async fn get_mut(&self, hash: &Hash) -> Result<Option<Self::EntryMut>>
Get an existing entry as an EntryMut. Read more
source§async fn get_or_create(&self, _hash: Hash, _size: u64) -> Result<Entry>
async fn get_or_create(&self, _hash: Hash, _size: u64) -> Result<Entry>
Get an existing partial entry, or create a new one. Read more
source§fn entry_status_sync(&self, hash: &Hash) -> Result<EntryStatus>
fn entry_status_sync(&self, hash: &Hash) -> Result<EntryStatus>
Sync version of
entry_status
, for the doc sync engine until we can get rid of it. Read moresource§async fn entry_status(&self, hash: &Hash) -> Result<EntryStatus>
async fn entry_status(&self, hash: &Hash) -> Result<EntryStatus>
Find out if the data behind a
hash
is complete, partial, or not present. Read moresource§impl ReadableStore for Store
impl ReadableStore for Store
source§async fn blobs(&self) -> Result<DbIter<Hash>>
async fn blobs(&self) -> Result<DbIter<Hash>>
list all blobs in the database. This includes both raw blobs that have
been imported, and hash sequences that have been created internally.
list all tags (collections or other explicitly added things) in the database
Temp tags
source§async fn consistency_check(
&self,
_repair: bool,
_tx: BoxedProgressSender<ConsistencyCheckProgress>
) -> Result<()>
async fn consistency_check( &self, _repair: bool, _tx: BoxedProgressSender<ConsistencyCheckProgress> ) -> Result<()>
Perform a consistency check on the database
source§async fn export(
&self,
hash: Hash,
target: PathBuf,
mode: ExportMode,
progress: ExportProgressCb
) -> Result<()>
async fn export( &self, hash: Hash, target: PathBuf, mode: ExportMode, progress: ExportProgressCb ) -> Result<()>
This trait method extracts a file to a local path. Read more
source§impl Store for Store
impl Store for Store
source§async fn import_bytes(
&self,
bytes: Bytes,
format: BlobFormat
) -> Result<TempTag>
async fn import_bytes( &self, bytes: Bytes, format: BlobFormat ) -> Result<TempTag>
import a byte slice
source§async fn import_file(
&self,
data: PathBuf,
mode: ImportMode,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> Result<(TempTag, u64)>
async fn import_file( &self, data: PathBuf, mode: ImportMode, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> Result<(TempTag, u64)>
This trait method imports a file from a local path. Read more
source§async fn import_stream(
&self,
data: impl Stream<Item = Result<Bytes>> + Unpin + Send,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> Result<(TempTag, u64)>
async fn import_stream( &self, data: impl Stream<Item = Result<Bytes>> + Unpin + Send, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> Result<(TempTag, u64)>
Import data from a stream of bytes.
source§async fn create_tag(&self, _hash: HashAndFormat) -> Result<Tag>
async fn create_tag(&self, _hash: HashAndFormat) -> Result<Tag>
Create a new tag
source§fn temp_tag(&self, inner: HashAndFormat) -> TempTag
fn temp_tag(&self, inner: HashAndFormat) -> TempTag
Create a temporary pin for this store
source§async fn delete(&self, _hashes: Vec<Hash>) -> Result<()>
async fn delete(&self, _hashes: Vec<Hash>) -> Result<()>
physically delete the given hashes from the store.
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
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.
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.