Struct iroh_bytes::store::readonly_mem::Store
source · pub struct Store(/* private fields */);Expand description
A readonly in memory database for iroh-bytes.
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.
Trait Implementations§
source§impl<K, V> FromIterator<(K, V)> for Store
impl<K, V> FromIterator<(K, V)> for Store
source§impl Map for Store
impl Map for Store
§type Outboard = PreOrderMemOutboard<Bytes>
type Outboard = PreOrderMemOutboard<Bytes>
The outboard type. This can be an in memory outboard or an outboard that
retrieves the data asynchronously from a remote database.
§type DataReader = Bytes
type DataReader = Bytes
The reader type.
source§impl MapEntry<Store> for Entry
impl MapEntry<Store> for Entry
source§fn available_ranges(&self) -> BoxFuture<'_, Result<ChunkRanges>>
fn available_ranges(&self) -> BoxFuture<'_, Result<ChunkRanges>>
Compute the available ranges. Read more
source§fn outboard(&self) -> BoxFuture<'_, Result<PreOrderMemOutboard<Bytes>>>
fn outboard(&self) -> BoxFuture<'_, Result<PreOrderMemOutboard<Bytes>>>
A future that resolves to a reader that can be used to read the outboard
source§fn data_reader(&self) -> BoxFuture<'_, Result<Bytes>>
fn data_reader(&self) -> BoxFuture<'_, Result<Bytes>>
A future that resolves to a reader that can be used to read the data
source§fn is_complete(&self) -> bool
fn is_complete(&self) -> bool
Returns
true if the entry is complete. Read moresource§impl MapEntry<Store> for PartialEntry
impl MapEntry<Store> for PartialEntry
source§fn available_ranges(&self) -> BoxFuture<'_, Result<ChunkRanges>>
fn available_ranges(&self) -> BoxFuture<'_, Result<ChunkRanges>>
Compute the available ranges. Read more
source§fn outboard(&self) -> BoxFuture<'_, Result<PreOrderMemOutboard<Bytes>>>
fn outboard(&self) -> BoxFuture<'_, Result<PreOrderMemOutboard<Bytes>>>
A future that resolves to a reader that can be used to read the outboard
source§fn data_reader(&self) -> BoxFuture<'_, Result<Bytes>>
fn data_reader(&self) -> BoxFuture<'_, Result<Bytes>>
A future that resolves to a reader that can be used to read the data
source§fn is_complete(&self) -> bool
fn is_complete(&self) -> bool
Returns
true if the entry is complete. Read moresource§impl PartialMap for Store
impl PartialMap for Store
§type OutboardMut = PreOrderOutboard<BytesMut>
type OutboardMut = PreOrderOutboard<BytesMut>
The outboard type to write data to the partial entry.
§type DataWriter = BytesMut
type DataWriter = BytesMut
The writer type to write data to the partial entry.
§type PartialEntry = PartialEntry
type PartialEntry = PartialEntry
A partial entry. This is an entry that is writeable and possibly incomplete. Read more
source§fn get_or_create_partial(&self, _hash: Hash, _size: u64) -> Result<PartialEntry>
fn get_or_create_partial(&self, _hash: Hash, _size: u64) -> Result<PartialEntry>
Get an existing partial entry, or create a new one. Read more
source§fn entry_status(&self, hash: &Hash) -> EntryStatus
fn entry_status(&self, hash: &Hash) -> EntryStatus
Find out if the data behind a
hash is complete, partial, or not present. Read moresource§fn get_possibly_partial(&self, hash: &Hash) -> PossiblyPartialEntry<Self>
fn get_possibly_partial(&self, hash: &Hash) -> PossiblyPartialEntry<Self>
Get an existing entry. Read more
source§fn insert_complete(&self, _entry: PartialEntry) -> BoxFuture<'_, Result<()>>
fn insert_complete(&self, _entry: PartialEntry) -> BoxFuture<'_, Result<()>>
Upgrade a partial entry to a complete entry.
source§impl PartialMapEntry<Store> for PartialEntry
impl PartialMapEntry<Store> for PartialEntry
source§fn outboard_mut(
&self
) -> BoxFuture<'_, Result<<Store as PartialMap>::OutboardMut>>
fn outboard_mut( &self ) -> BoxFuture<'_, Result<<Store as PartialMap>::OutboardMut>>
A future that resolves to an writeable outboard
source§fn data_writer(
&self
) -> BoxFuture<'_, Result<<Store as PartialMap>::DataWriter>>
fn data_writer( &self ) -> BoxFuture<'_, Result<<Store as PartialMap>::DataWriter>>
A future that resolves to a writer that can be used to write the data
source§impl ReadableStore for Store
impl ReadableStore for Store
source§fn blobs(&self) -> Box<dyn Iterator<Item = Hash> + Send + Sync + 'static>
fn blobs(&self) -> Box<dyn Iterator<Item = Hash> + Send + Sync + 'static>
list all blobs in the database. This should include collections, since
collections are blobs and can be requested as blobs. Read more
list all tags (collections or other explicitly added things) in the database Read more
Temp tags
source§fn validate(
&self,
_tx: Sender<ValidateProgress>
) -> BoxFuture<'static, Result<()>>
fn validate( &self, _tx: Sender<ValidateProgress> ) -> BoxFuture<'static, Result<()>>
Validate the database
source§impl Store for Store
impl Store for Store
source§fn import_bytes(
&self,
bytes: Bytes,
format: BlobFormat
) -> BoxFuture<'_, Result<TempTag>>
fn import_bytes( &self, bytes: Bytes, format: BlobFormat ) -> BoxFuture<'_, Result<TempTag>>
import a byte slice
source§fn 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. Read more
source§fn import_stream(
&self,
data: impl Stream<Item = Result<Bytes>> + Unpin + Send,
format: BlobFormat,
progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator
) -> BoxFuture<'_, Result<(TempTag, u64)>>
fn import_stream( &self, data: impl Stream<Item = Result<Bytes>> + Unpin + Send, format: BlobFormat, progress: impl ProgressSender<Msg = ImportProgress> + IdGenerator ) -> BoxFuture<'_, Result<(TempTag, u64)>>
Import data from a stream of bytes.
source§fn clear_live(&self)
fn clear_live(&self)
Clear the live set.
source§fn set_tag(
&self,
_name: Tag,
_hash: Option<HashAndFormat>
) -> BoxFuture<'_, Result<()>>
fn set_tag( &self, _name: Tag, _hash: Option<HashAndFormat> ) -> BoxFuture<'_, Result<()>>
Set a tag
source§fn create_tag(&self, _hash: HashAndFormat) -> BoxFuture<'_, Result<Tag>>
fn create_tag(&self, _hash: HashAndFormat) -> BoxFuture<'_, 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§fn 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. Read more
source§fn delete(&self, _hash: &Hash) -> BoxFuture<'_, Result<()>>
fn delete(&self, _hash: &Hash) -> BoxFuture<'_, Result<()>>
physically delete the given hash from the store.
source§fn 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.
source§fn 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. Read more
source§fn gc_sweep(&self) -> LocalBoxStream<'_, GcSweepEvent>
fn gc_sweep(&self) -> LocalBoxStream<'_, GcSweepEvent>
Remove all blobs that are not marked as live. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
Blanket Implementations§
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