Skip to main content

MemoryBlobStore

Struct MemoryBlobStore 

Source
pub struct MemoryBlobStore<H: HashProtocol> { /* private fields */ }
Expand description

Re-export of the in-memory blob store. A mapping from Handles to Blobs.

Implementations§

Source§

impl<H: HashProtocol> MemoryBlobStore<H>

Source

pub fn new() -> MemoryBlobStore<H>

Creates a new MemoryBlobStore with no blobs.

The store keeps all data in memory and is primarily intended for tests or other transient repositories such as workspaces.

Source

pub fn insert<S>(&mut self, blob: Blob<S>) -> Value<Handle<H, S>>
where S: BlobSchema,

Inserts blob into the store and returns the newly computed handle.

The handle is derived from hashing the blob’s bytes using the hash protocol associated with this store.

Source

pub fn keep<I>(&mut self, handles: I)
where I: IntoIterator<Item = Value<Handle<H, UnknownBlob>>>,

Drops any blobs that are not referenced by one of the provided tribles.

This is a simple mark-and-sweep style GC used to prune unreferenced blobs from long lived stores.

Trait Implementations§

Source§

impl<H: HashProtocol> BlobStore<H> for MemoryBlobStore<H>

Source§

type Reader = MemoryBlobStoreReader<H>

A clonable reader handle for concurrent blob lookups.
Source§

type ReaderError = Infallible

Error type for creating a reader.
Source§

fn reader(&mut self) -> Result<Self::Reader, Self::ReaderError>

Creates a shareable reader snapshot of the current store state.
Source§

impl<H: HashProtocol> BlobStoreKeep<H> for MemoryBlobStore<H>

Source§

fn keep<I>(&mut self, handles: I)
where I: IntoIterator<Item = Value<Handle<H, UnknownBlob>>>,

Retain only the blobs identified by handles.
Source§

impl<H> BlobStorePut<H> for MemoryBlobStore<H>
where H: HashProtocol,

Source§

type PutError = Infallible

Error type for put operations.
Source§

fn put<S, T>(&mut self, item: T) -> Result<Value<Handle<H, S>>, Self::PutError>
where S: BlobSchema, T: ToBlob<S>,

Serialises item as a blob, stores it, and returns its handle.
Source§

impl<H> Debug for MemoryBlobStore<H>
where H: HashProtocol,

Source§

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

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

impl<H: HashProtocol> Default for MemoryBlobStore<H>

Source§

fn default() -> Self

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

impl<H> FromIterator<(Value<Handle<H, UnknownBlob>>, Blob<UnknownBlob>)> for MemoryBlobStore<H>
where H: HashProtocol,

Source§

fn from_iter<I: IntoIterator<Item = (Value<Handle<H, UnknownBlob>>, Blob<UnknownBlob>)>>( iter: I, ) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<H> !Freeze for MemoryBlobStore<H>

§

impl<H> !RefUnwindSafe for MemoryBlobStore<H>

§

impl<H> Send for MemoryBlobStore<H>

§

impl<H> !Sync for MemoryBlobStore<H>

§

impl<H> Unpin for MemoryBlobStore<H>

§

impl<H> UnsafeUnpin for MemoryBlobStore<H>

§

impl<H> !UnwindSafe for MemoryBlobStore<H>

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

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

Source§

fn vzip(self) -> V