MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore<C = FixedSizeChunker, L = FlatLayout>
where C: Chunker, L: Layout,
{ /* private fields */ }
Expand description

An in-memory storage for IPLD node and raw blocks with reference counting.

This store maintains a reference count for each stored block. Reference counting is used to determine when a block can be safely removed from the store.

Implementations§

Source§

impl<C, L> MemoryStore<C, L>
where C: Chunker, L: Layout,

Source

pub fn new(chunker: C, layout: L) -> Self

Creates a new MemoryStore with the given chunker and layout.

Source

pub fn debug(&self)
where C: Clone + Send, L: Clone + Send,

Prints all the blocks in the store.

Trait Implementations§

Source§

impl<C, L> Clone for MemoryStore<C, L>
where C: Chunker + Clone, L: Layout + Clone,

Source§

fn clone(&self) -> MemoryStore<C, L>

Returns a duplicate 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<C, L> Debug for MemoryStore<C, L>
where C: Chunker + Debug, L: Layout + Debug,

Source§

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

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

impl Default for MemoryStore

Source§

fn default() -> Self

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

impl<C, L> IpldStore for MemoryStore<C, L>
where C: Chunker + Clone + Send + Sync, L: Layout + Clone + Send + Sync,

Source§

async fn put_node<T>(&self, data: &T) -> StoreResult<Cid>

Saves an IPLD serializable object to the store and returns the Cid to it. Read more
Source§

async fn put_bytes<'a>( &'a self, reader: impl AsyncRead + Send + Sync + 'a, ) -> StoreResult<Cid>

Takes a reader of raw bytes, saves it to the store and returns the Cid to it. Read more
Source§

async fn put_raw_block(&self, bytes: impl Into<Bytes>) -> StoreResult<Cid>

Tries to save bytes as a single block to the store. Unlike put_bytes, this method does not chunk the data and does not create intermediate merkle nodes. Read more
Source§

async fn get_node<T>(&self, cid: &Cid) -> StoreResult<T>

Gets a type stored as an IPLD data from the store by its Cid. Read more
Source§

async fn get_bytes<'a>( &'a self, cid: &'a Cid, ) -> StoreResult<Pin<Box<dyn AsyncRead + Send + Sync + 'a>>>

Gets a reader for the underlying bytes associated with the given Cid. Read more
Source§

async fn get_raw_block(&self, cid: &Cid) -> StoreResult<Bytes>

Retrieves raw bytes of a single block from the store by its Cid. Read more
Source§

async fn has(&self, cid: &Cid) -> bool

Checks if the store has a block with the given Cid.
Source§

fn get_supported_codecs(&self) -> HashSet<Codec>

Returns the codecs supported by the store.
Source§

fn get_node_block_max_size(&self) -> Option<u64>

Returns the allowed maximum block size for IPLD and merkle nodes. If there is no limit, None is returned.
Source§

fn get_raw_block_max_size(&self) -> Option<u64>

Returns the allowed maximum block size for raw bytes. If there is no limit, None is returned.
Source§

async fn is_empty(&self) -> StoreResult<bool>

Checks if the store is empty.
Source§

async fn get_size(&self) -> StoreResult<u64>

Returns the number of blocks in the store.
Source§

impl<C, L> IpldStoreSeekable for MemoryStore<C, L>
where C: Chunker + Clone + Send + Sync, L: LayoutSeekable + Clone + Send + Sync,

Source§

async fn get_seekable_bytes<'a>( &'a self, cid: &'a Cid, ) -> StoreResult<Pin<Box<dyn SeekableReader + Send + 'a>>>

Gets a seekable reader for the underlying bytes associated with the given Cid.

Auto Trait Implementations§

§

impl<C, L> Freeze for MemoryStore<C, L>
where C: Freeze, L: Freeze,

§

impl<C = FixedSizeChunker, L = FlatLayout> !RefUnwindSafe for MemoryStore<C, L>

§

impl<C, L> Send for MemoryStore<C, L>
where C: Send, L: Send,

§

impl<C, L> Sync for MemoryStore<C, L>
where C: Sync, L: Sync,

§

impl<C, L> Unpin for MemoryStore<C, L>
where C: Unpin, L: Unpin,

§

impl<C = FixedSizeChunker, L = FlatLayout> !UnwindSafe for MemoryStore<C, L>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IpldStoreExt for T
where T: IpldStore,

Source§

fn read_all(&self, cid: &Cid) -> impl Future<Output = StoreResult<Bytes>>

Reads all the bytes associated with the given Cid into a single Bytes type.
Source§

impl<T> References<RawCodec> for T

Source§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>
where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.