pub trait Store:
Clone
+ Send
+ Sync {
type Params: StoreParams;
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
cid: &'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>,
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block<Self::Params>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn alias<'life0, 'life1, 'async_trait, T>(
&'life0 self,
alias: T,
cid: Option<&'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
T: 'async_trait + AsRef<[u8]> + Send + Sync,
Self: 'async_trait;
fn resolve<'life0, 'async_trait, T>(
&'life0 self,
alias: T,
) -> Pin<Box<dyn Future<Output = Result<Option<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
T: 'async_trait + AsRef<[u8]> + Send + Sync,
Self: 'async_trait;
// Provided method
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
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§
Sourcetype Params: StoreParams
type Params: StoreParams
Store parameters.
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
cid: &'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>,
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
cid: &'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>,
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
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.
Sourcefn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block<Self::Params>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block<Self::Params>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Inserts a block into the store and publishes the block on the network.
Sourcefn alias<'life0, 'life1, 'async_trait, T>(
&'life0 self,
alias: T,
cid: Option<&'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn alias<'life0, 'life1, 'async_trait, T>( &'life0 self, alias: T, cid: Option<&'life1 Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Creates an alias for a Cid
. To alias a block all it’s recursive references
must be in the store. If blocks are missing, they will be fetched from the network. If
they aren’t found, it will return a BlockNotFound
error.
Provided Methods§
Sourcefn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
Self: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 DagPath<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
Self: 'async_trait,
Resolves a path recursively and returns the ipld.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.