pub struct DualStore<A, B>{ /* private fields */ }Expand description
A dual store that stores blocks on two different stores.
Implementations§
Source§impl<A, B> DualStore<A, B>
impl<A, B> DualStore<A, B>
Sourcepub fn new(store_a: A, store_b: B, config: DualStoreConfig) -> Self
pub fn new(store_a: A, store_b: B, config: DualStoreConfig) -> Self
Creates a new dual store from two stores.
Sourcepub async fn get_node_from<D>(
&self,
cid: &Cid,
choice: Choice,
) -> StoreResult<D>where
D: DeserializeOwned + Send,
pub async fn get_node_from<D>(
&self,
cid: &Cid,
choice: Choice,
) -> StoreResult<D>where
D: DeserializeOwned + Send,
Gets the type stored as an IPLD data from a chosen store by its Cid.
Sourcepub async fn get_bytes_from<'a>(
&'a self,
cid: &'a Cid,
choice: Choice,
) -> StoreResult<Pin<Box<dyn AsyncRead + Send + Sync + 'a>>>
pub async fn get_bytes_from<'a>( &'a self, cid: &'a Cid, choice: Choice, ) -> StoreResult<Pin<Box<dyn AsyncRead + Send + Sync + 'a>>>
Gets the bytes stored in a chosen store as raw bytes by its Cid.
Sourcepub async fn get_raw_block_from(
&self,
cid: &Cid,
choice: Choice,
) -> StoreResult<Bytes>
pub async fn get_raw_block_from( &self, cid: &Cid, choice: Choice, ) -> StoreResult<Bytes>
Gets raw bytes from a chosen store as a single block by its Cid.
Sourcepub async fn put_node_into<T>(
&self,
data: &T,
choice: Choice,
) -> StoreResult<Cid>
pub async fn put_node_into<T>( &self, data: &T, choice: Choice, ) -> StoreResult<Cid>
Saves a serializable type to a chosen store and returns the Cid to it.
Sourcepub async fn put_bytes_into(
&self,
bytes: impl AsyncRead + Send + Sync,
choice: Choice,
) -> StoreResult<Cid>
pub async fn put_bytes_into( &self, bytes: impl AsyncRead + Send + Sync, choice: Choice, ) -> StoreResult<Cid>
Saves raw bytes to a chosen store and returns the Cid to it.
Sourcepub async fn put_raw_block_into(
&self,
bytes: impl Into<Bytes> + Send,
choice: Choice,
) -> StoreResult<Cid>
pub async fn put_raw_block_into( &self, bytes: impl Into<Bytes> + Send, choice: Choice, ) -> StoreResult<Cid>
Saves raw bytes as a single block to a chosen store and returns the Cid to it.
Trait Implementations§
Source§impl<A, B> IpldStore for DualStore<A, B>
impl<A, B> IpldStore for DualStore<A, B>
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,
bytes: impl AsyncRead + Send + Sync + 'a,
) -> StoreResult<Cid>
async fn put_bytes<'a>( &'a self, bytes: 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> + Send,
) -> StoreResult<Cid>
async fn put_raw_block( &self, bytes: impl Into<Bytes> + Send, ) -> 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<D>(&self, cid: &Cid) -> StoreResult<D>where
D: DeserializeOwned + Send,
async fn get_node<D>(&self, cid: &Cid) -> StoreResult<D>where
D: DeserializeOwned + Send,
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.
Auto Trait Implementations§
impl<A, B> Freeze for DualStore<A, B>
impl<A, B> RefUnwindSafe for DualStore<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for DualStore<A, B>
impl<A, B> Sync for DualStore<A, B>
impl<A, B> Unpin for DualStore<A, B>
impl<A, B> UnwindSafe for DualStore<A, B>where
A: UnwindSafe,
B: UnwindSafe,
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