pub struct Repo { /* private fields */ }
Expand description
Describes a repo.
Consolidates a blockstore, a datastore and a subscription registry.
Implementations§
source§impl Repo
impl Repo
pub fn new(repo_type: &mut StoragePath, duration: Option<Duration>) -> Self
pub fn new_raw( block_store: Box<dyn BlockStore>, data_store: Box<dyn DataStore>, lockfile: Box<dyn Lock> ) -> Self
pub fn new_fs( path: impl AsRef<Path>, duration: impl Into<Option<Duration>> ) -> Self
pub fn new_memory(duration: impl Into<Option<Duration>>) -> Self
pub fn set_max_storage_size(&self, size: usize)
pub fn max_storage_size(&self) -> usize
pub async fn migrate(&self, repo: &Self) -> Result<(), Error>
sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Shutdowns the repo, cancelling any pending subscriptions; Likely going away after some
refactoring, see notes on crate::Ipfs::exit_daemon
.
pub fn is_online(&self) -> bool
pub async fn init(&self) -> Result<(), Error>
pub async fn open(&self) -> Result<(), Error>
sourcepub async fn put_block(&self, block: Block) -> Result<(Cid, BlockPut), Error>
pub async fn put_block(&self, block: Block) -> Result<(Cid, BlockPut), Error>
Puts a block into the block store.
sourcepub async fn get_block(
&self,
cid: &Cid,
peers: &[PeerId],
local_only: bool
) -> Result<Block, Error>
pub async fn get_block( &self, cid: &Cid, peers: &[PeerId], local_only: bool ) -> Result<Block, Error>
Retrives a block from the block store, or starts fetching it from the network and awaits until it has been fetched.
sourcepub async fn get_blocks(
&self,
cids: &[Cid],
peers: &[PeerId],
local_only: bool
) -> Result<BoxStream<'static, Result<Block, Error>>, Error>
pub async fn get_blocks( &self, cids: &[Cid], peers: &[PeerId], local_only: bool ) -> Result<BoxStream<'static, Result<Block, Error>>, Error>
Retrives a set of blocks from the block store, or starts fetching them from the network and awaits until it has been fetched.
sourcepub async fn get_blocks_size(
&self,
cids: &[Cid]
) -> Result<Option<usize>, Error>
pub async fn get_blocks_size( &self, cids: &[Cid] ) -> Result<Option<usize>, Error>
Get the size of listed blocks
sourcepub async fn get_total_size(&self) -> Result<usize, Error>
pub async fn get_total_size(&self) -> Result<usize, Error>
Get the total size of the block store
sourcepub async fn get_block_now(&self, cid: &Cid) -> Result<Option<Block>, Error>
pub async fn get_block_now(&self, cid: &Cid) -> Result<Option<Block>, Error>
Retrieves a block from the block store if it’s available locally.
sourcepub async fn contains(&self, cid: &Cid) -> Result<bool, Error>
pub async fn contains(&self, cid: &Cid) -> Result<bool, Error>
Check to determine if blockstore contain a block
sourcepub async fn list_blocks(&self) -> Result<Vec<Cid>, Error>
pub async fn list_blocks(&self) -> Result<Vec<Cid>, Error>
Lists the blocks in the blockstore.
sourcepub async fn remove_block(
&self,
cid: &Cid,
recursive: bool
) -> Result<Vec<Cid>, Error>
pub async fn remove_block( &self, cid: &Cid, recursive: bool ) -> Result<Vec<Cid>, Error>
Remove block from the block store.
sourcepub fn pin(&self, cid: &Cid) -> RepoInsertPin
pub fn pin(&self, cid: &Cid) -> RepoInsertPin
Pins a given Cid recursively or directly (non-recursively).
Pins on a block are additive in sense that a previously directly (non-recursively) pinned can be made recursive, but removing the recursive pin on the block removes also the direct pin as well.
Pinning a Cid recursively (for supported dag-protobuf and dag-cbor) will walk its references and pin the references indirectly. When a Cid is pinned indirectly it will keep its previous direct or recursive pin and be indirect in addition.
Recursively pinned Cids cannot be re-pinned non-recursively but non-recursively pinned Cids can be “upgraded to” being recursively pinned.
sourcepub fn remove_pin(&self, cid: &Cid) -> RepoRemovePin
pub fn remove_pin(&self, cid: &Cid) -> RepoRemovePin
Unpins a given Cid recursively or only directly.
Recursively unpinning a previously only directly pinned Cid will remove the direct pin.
Unpinning an indirectly pinned Cid is not possible other than through its recursively pinned tree roots.
sourcepub async fn insert_pin(
&self,
cid: &Cid,
recursive: bool,
local_only: bool
) -> Result<(), Error>
pub async fn insert_pin( &self, cid: &Cid, recursive: bool, local_only: bool ) -> Result<(), Error>
Pins a given Cid recursively or directly (non-recursively).
sourcepub async fn cleanup(&self) -> Result<Vec<Cid>, Error>
pub async fn cleanup(&self) -> Result<Vec<Cid>, Error>
Function to perform a basic cleanup of unpinned blocks