pub struct MemoryStore<C = FixedSizeChunker, L = FlatLayout>{ /* 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§
Trait Implementations§
Source§impl<C, L> Clone for MemoryStore<C, L>
impl<C, L> Clone for MemoryStore<C, L>
Source§fn clone(&self) -> MemoryStore<C, L>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C, L> Debug for MemoryStore<C, L>
impl<C, L> Debug for MemoryStore<C, L>
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl<C, L> IpldStore for MemoryStore<C, L>
impl<C, L> IpldStore for MemoryStore<C, L>
Source§async fn put_node<T>(&self, data: &T) -> StoreResult<Cid>
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 moreSource§async fn put_bytes<'a>(
&'a self,
reader: impl AsyncRead + Send + Sync + 'a,
) -> StoreResult<Cid>
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 moreSource§async fn put_raw_block(&self, bytes: impl Into<Bytes>) -> StoreResult<Cid>
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 moreSource§async fn get_node<T>(&self, cid: &Cid) -> StoreResult<T>where
T: DeserializeOwned,
async fn get_node<T>(&self, cid: &Cid) -> StoreResult<T>where
T: DeserializeOwned,
Gets a type stored as an IPLD data from the store by its
Cid. Read moreSource§async fn get_bytes<'a>(
&'a self,
cid: &'a Cid,
) -> StoreResult<Pin<Box<dyn AsyncRead + Send + Sync + 'a>>>
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 moreSource§async fn get_raw_block(&self, cid: &Cid) -> StoreResult<Bytes>
async fn get_raw_block(&self, cid: &Cid) -> StoreResult<Bytes>
Retrieves raw bytes of a single block from the store by its
Cid. Read moreSource§fn get_supported_codecs(&self) -> HashSet<Codec>
fn get_supported_codecs(&self) -> HashSet<Codec>
Returns the codecs supported by the store.
Source§fn get_node_block_max_size(&self) -> Option<u64>
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>
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>
async fn is_empty(&self) -> StoreResult<bool>
Checks if the store is empty.
Source§async fn get_size(&self) -> StoreResult<u64>
async fn get_size(&self) -> StoreResult<u64>
Returns the number of blocks in the store.
Source§impl<C, L> IpldStoreSeekable for MemoryStore<C, L>
impl<C, L> IpldStoreSeekable for MemoryStore<C, L>
Source§async fn get_seekable_bytes<'a>(
&'a self,
cid: &'a Cid,
) -> StoreResult<Pin<Box<dyn SeekableReader + Send + 'a>>>
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>
impl<C = FixedSizeChunker, L = FlatLayout> !RefUnwindSafe for MemoryStore<C, L>
impl<C, L> Send for MemoryStore<C, L>
impl<C, L> Sync for MemoryStore<C, L>
impl<C, L> Unpin for MemoryStore<C, L>
impl<C = FixedSizeChunker, L = FlatLayout> !UnwindSafe for MemoryStore<C, L>
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