DualStore

Struct DualStore 

Source
pub struct DualStore<A, B>
where A: IpldStore, B: IpldStore,
{ /* private fields */ }
Expand description

A dual store that stores blocks on two different stores.

Implementations§

Source§

impl<A, B> DualStore<A, B>
where A: IpldStore, B: IpldStore,

Source

pub fn new(store_a: A, store_b: B, config: DualStoreConfig) -> Self

Creates a new dual store from two stores.

Source

pub async fn get_node_from<D>( &self, cid: &Cid, choice: Choice, ) -> StoreResult<D>

Gets the type stored as an IPLD data from a chosen store by its Cid.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn has_from(&self, cid: &Cid, choice: Choice) -> bool

Checks if a block exists in a chosen store by its Cid.

Trait Implementations§

Source§

impl<A, B> Clone for DualStore<A, B>
where A: IpldStore + Clone, B: IpldStore + Clone,

Source§

fn clone(&self) -> DualStore<A, B>

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<A, B> Debug for DualStore<A, B>
where A: IpldStore + Debug, B: IpldStore + Debug,

Source§

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

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

impl<A, B> IpldStore for DualStore<A, B>
where A: IpldStore + Sync, B: IpldStore + 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, 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 more
Source§

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

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

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.

Auto Trait Implementations§

§

impl<A, B> Freeze for DualStore<A, B>
where A: Freeze, B: Freeze,

§

impl<A, B> RefUnwindSafe for DualStore<A, B>

§

impl<A, B> Send for DualStore<A, B>
where A: Send, B: Send,

§

impl<A, B> Sync for DualStore<A, B>
where A: Sync, B: Sync,

§

impl<A, B> Unpin for DualStore<A, B>
where A: Unpin, B: Unpin,

§

impl<A, B> UnwindSafe for DualStore<A, B>
where A: UnwindSafe, B: UnwindSafe,

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.