[][src]Trait ipfs_embed_core::Store

pub trait Store: Clone + Send + Sync {
    type Params: StoreParams;
#[must_use]    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cid: &'life1 Cid
    ) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>, Error>> + 'async_trait + Send>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn insert<'life0, 'life1, 'async_trait>(
        &'life0 self,
        block: &'life1 Block<Self::Params>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait + Send>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn alias<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        alias: T,
        cid: Option<&'life1 Cid>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait + Send>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait,
        T: AsRef<[u8]> + Send + Sync + 'async_trait
;
#[must_use] fn resolve<'life0, 'async_trait, T>(
        &'life0 self,
        alias: T
    ) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, Error>> + 'async_trait + Send>>
    where
        'life0: 'async_trait,
        Self: 'async_trait,
        T: AsRef<[u8]> + Send + Sync + 'async_trait
; #[must_use] fn query<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        path: &'life1 DagPath<'life2>
    ) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + 'async_trait + Send>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait,
        Ipld: Decode<<Self::Params as StoreParams>::Codecs>
, { ... } }

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.

Associated Types

type Params: StoreParams

Store parameters.

Loading content...

Required methods

#[must_use]fn get<'life0, 'life1, 'async_trait>(
    &'life0 self,
    cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>, Error>> + 'async_trait + Send>> 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.

#[must_use]fn insert<'life0, 'life1, 'async_trait>(
    &'life0 self,
    block: &'life1 Block<Self::Params>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Inserts a block into the store and publishes the block on the network.

#[must_use]fn alias<'life0, 'life1, 'async_trait, T>(
    &'life0 self,
    alias: T,
    cid: Option<&'life1 Cid>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait,
    T: AsRef<[u8]> + Send + Sync + '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.

#[must_use]fn resolve<'life0, 'async_trait, T>(
    &'life0 self,
    alias: T
) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    Self: 'async_trait,
    T: AsRef<[u8]> + Send + Sync + 'async_trait, 

Resolves an alias for a Cid.

Loading content...

Provided methods

#[must_use]fn query<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    path: &'life1 DagPath<'life2>
) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + 'async_trait + Send>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    Ipld: Decode<<Self::Params as StoreParams>::Codecs>, 

Resolves a path recursively and returns the ipld.

Loading content...

Implementations on Foreign Types

impl<S> Store for MemStore<S> where
    S: StoreParams,
    Ipld: Decode<<S as StoreParams>::Codecs>, 
[src]

type Params = S

Loading content...

Implementors

Loading content...