Trait libipld::store::Store[][src]

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>>>>;
#[must_use] fn flush<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] 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
;
#[must_use] 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
; #[must_use] 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
, { ... } }

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[src]

Store parameters.

type TempPin: Clone + Send + Sync[src]

Temp pin.

Loading content...

Required methods

fn create_temp_pin(&self) -> Result<Self::TempPin>[src]

Creates a new temporary pin.

fn temp_pin(&self, tmp: &Self::TempPin, cid: &Cid) -> Result<()>[src]

Adds a block to a temp pin.

fn contains(&self, cid: &Cid) -> Result<bool>[src]

Returns true if the store contains the block.

fn get(&self, cid: &Cid) -> Result<Block<Self::Params>>[src]

Returns a block from the store. If the block wasn't found it returns a BlockNotFound error.

fn insert(&self, block: &Block<Self::Params>) -> Result<()>[src]

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

fn alias<T: AsRef<[u8]> + Send + Sync>(
    &self,
    alias: T,
    cid: Option<&Cid>
) -> Result<()>
[src]

Creates an alias for a Cid.

fn resolve<T: AsRef<[u8]> + Send + Sync>(&self, alias: T) -> Result<Option<Cid>>[src]

Resolves an alias for a Cid.

fn reverse_alias(&self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>[src]

Returns all the aliases that are keeping the block around.

#[must_use]fn flush<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Flushes the store.

#[must_use]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, 
[src]

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 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, 
[src]

Fetches all missing blocks recursively from the network. If a block isn't found it returns a BlockNotFound error.

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>> + Send + 'async_trait>> where
    Ipld: Decode<<Self::Params as StoreParams>::Codecs>,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

Resolves a path recursively and returns the ipld.

Loading content...

Implementors

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

type Params = S

type TempPin = TempPin

Loading content...