pub struct MemoryBlockStore(/* private fields */);Expand description
An in-memory block store to simulate IPFS.
IPFS is basically a glorified HashMap.
Implementations§
Trait Implementations§
Source§impl BlockStore for MemoryBlockStore
impl BlockStore for MemoryBlockStore
Source§async fn get_block(&self, cid: &Cid) -> Result<Bytes, BlockStoreError>
async fn get_block(&self, cid: &Cid) -> Result<Bytes, BlockStoreError>
Retrieve a block from this store via its hash (
Cid). Read moreSource§async fn put_block_keyed(
&self,
cid: Cid,
bytes: impl Into<Bytes> + CondSend,
) -> Result<(), BlockStoreError>
async fn put_block_keyed( &self, cid: Cid, bytes: impl Into<Bytes> + CondSend, ) -> Result<(), BlockStoreError>
Put a block of data into this blockstore. The block’s CID needs to match the CID given. Read more
Source§async fn has_block(&self, cid: &Cid) -> Result<bool, BlockStoreError>
async fn has_block(&self, cid: &Cid) -> Result<bool, BlockStoreError>
Find out whether a call to
get_block would return with a result or not. Read moreSource§fn put_block(
&self,
bytes: impl Into<Bytes> + CondSend,
codec: u64,
) -> impl Future<Output = Result<Cid, BlockStoreError>> + CondSend
fn put_block( &self, bytes: impl Into<Bytes> + CondSend, codec: u64, ) -> impl Future<Output = Result<Cid, BlockStoreError>> + CondSend
Put some bytes into the blockstore. These bytes should be encoded with the given codec. Read more
fn create_cid(&self, bytes: &[u8], codec: u64) -> Result<Cid, BlockStoreError>
Source§impl Clone for MemoryBlockStore
impl Clone for MemoryBlockStore
Source§fn clone(&self) -> MemoryBlockStore
fn clone(&self) -> MemoryBlockStore
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 Debug for MemoryBlockStore
impl Debug for MemoryBlockStore
Source§impl Default for MemoryBlockStore
impl Default for MemoryBlockStore
Source§fn default() -> MemoryBlockStore
fn default() -> MemoryBlockStore
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MemoryBlockStore
impl<'de> Deserialize<'de> for MemoryBlockStore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MemoryBlockStore
impl !RefUnwindSafe for MemoryBlockStore
impl Send for MemoryBlockStore
impl Sync for MemoryBlockStore
impl Unpin for MemoryBlockStore
impl !UnwindSafe for MemoryBlockStore
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