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

source

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.

source

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.

source

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.

source

pub fn get_content(&self, hash: &Hash) -> Option<Bytes>

Get the bytes associated with a hash, if they exist.

Trait Implementations§

source§

impl Clone for Store

source§

fn clone(&self) -> Store

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Store

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Store

source§

fn default() -> Store

Returns the “default value” for a type. Read more
source§

impl<K, V> FromIterator<(K, V)> for Store
where K: Into<String>, V: AsRef<[u8]>,

source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Map for Store

§

type Entry = Entry

The entry type. An entry is a cheaply cloneable handle that can be used to open readers for both the data and the outboard
source§

async fn get(&self, hash: &Hash) -> Result<Option<Self::Entry>>

Get an entry for a hash. Read more
source§

impl MapMut for Store

§

type EntryMut = Entry

An entry that is possibly writable
source§

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>

Get an existing partial entry, or create a new one. Read more
source§

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 more
source§

async fn entry_status(&self, hash: &Hash) -> Result<EntryStatus>

Find out if the data behind a hash is complete, partial, or not present. Read more
source§

async fn insert_complete(&self, _entry: Entry) -> Result<()>

Upgrade a partial entry to a complete entry.
source§

impl ReadableStore for Store

source§

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.
source§

async fn tags(&self) -> Result<DbIter<(Tag, HashAndFormat)>>

list all tags (collections or other explicitly added things) in the database
source§

fn temp_tags( &self ) -> Box<dyn Iterator<Item = HashAndFormat> + Send + Sync + 'static>

Temp tags
source§

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<()>

This trait method extracts a file to a local path. Read more
source§

async fn partial_blobs(&self) -> Result<DbIter<Hash>>

list partial blobs in the database
source§

impl Store for Store

source§

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)>

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)>

Import data from a stream of bytes.
source§

async fn set_tag(&self, _name: Tag, _hash: Option<HashAndFormat>) -> Result<()>

Set a tag
source§

async fn create_tag(&self, _hash: HashAndFormat) -> Result<Tag>

Create a new tag
source§

fn temp_tag(&self, inner: HashAndFormat) -> TempTag

Create a temporary pin for this store
source§

async fn gc_run<G, Gut>(&self, config: GcConfig, protected_cb: G)
where G: Fn() -> Gut, Gut: Future<Output = BTreeSet<Hash>> + Send,

Start the GC loop Read more
source§

async fn delete(&self, _hashes: Vec<Hash>) -> Result<()>

physically delete the given hashes from the store.
source§

async fn shutdown(&self)

Shutdown the store.
source§

async fn sync(&self) -> Result<()>

Sync 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

Import data from an async byte reader.
source§

fn import_verifiable_stream<'a>( &'a self, hash: Hash, total_size: u64, offset: u64, reader: impl AsyncStreamReader + 'a ) -> impl Future<Output = Result<()>> + 'a

Import a blob from a verified stream, as emitted by MapEntry::write_verifiable_stream; Read more
source§

fn validate( &self, repair: bool, tx: BoxedProgressSender<ValidateProgress> ) -> impl Future<Output = Result<()>> + Send

Validate the database Read more

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T