pub trait Store: Clone + Send + Sync {
type Params: StoreParams;
type TempPin: Clone + Send + Sync;
fn create_temp_pin(&self) -> Result<Self::TempPin>;
fn temp_pin(&self, tmp: &Self::TempPin, cid: &Cid) -> Result<()>;
fn contains(&self, cid: &Cid) -> Result<bool>;
fn get(&self, cid: &Cid) -> Result<Block<Self::Params>>;
fn insert(&self, block: &Block<Self::Params>) -> Result<()>;
fn alias<T: AsRef<[u8]> + Send + Sync>(
&self,
alias: T,
cid: Option<&Cid>
) -> Result<()>;
fn resolve<T: AsRef<[u8]> + Send + Sync>(
&self,
alias: T
) -> Result<Option<Cid>>;
fn reverse_alias(&self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>;
fn flush<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn fetch<'life0, 'life1, 'async_trait>(
&'life0 self,
cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn sync<'life0, 'life1, 'async_trait>(
&'life0 self,
cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>
) -> Pin<Box<dyn Future<Output = Result<Ipld>> + Send + 'async_trait>>
where
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
{ ... }
}Expand description
Implementable by ipld stores. An ipld store behaves like a cache. It will keep blocks until the cache is full after which it evicts blocks based on an eviction policy. If a block is aliased (recursive named pin), it and it’s recursive references will not be evicted or counted towards the cache size.
Required Associated Types
Required Methods
fn create_temp_pin(&self) -> Result<Self::TempPin>
fn create_temp_pin(&self) -> Result<Self::TempPin>
Creates a new temporary pin.
Returns a block from the store. If the block wasn’t found it returns a BlockNotFound
error.
Inserts a block into the store and publishes the block on the network.
Creates an alias for a Cid.
Resolves an alias for a Cid.
Returns all the aliases that are keeping the block around.
Flushes the store.
Returns a block from the store. If the store supports networking and the block is not in the store it fetches it from the network and inserts it into the store. Dropping the future cancels the request.
If the block wasn’t found it returns a BlockNotFound error.
Fetches all missing blocks recursively from the network. If a block isn’t found it
returns a BlockNotFound error.
Provided Methods
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>
) -> Pin<Box<dyn Future<Output = Result<Ipld>> + Send + 'async_trait>> where
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>
) -> Pin<Box<dyn Future<Output = Result<Ipld>> + Send + 'async_trait>> where
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Resolves a path recursively and returns the ipld.