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: StoragePath) -> Self
pub fn new_raw( block_store: Arc<dyn BlockStore>, data_store: Arc<dyn DataStore>, lockfile: Arc<dyn Lock> ) -> Self
pub fn new_fs(path: impl AsRef<Path>) -> Self
pub fn new_memory() -> Self
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_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) -> Result<Cid, Error>
pub async fn remove_block(&self, cid: &Cid) -> Result<Cid, Error>
Remove block from the block store.
sourcepub async fn get_ipns(&self, ipns: &PeerId) -> Result<Option<IpfsPath>, Error>
pub async fn get_ipns(&self, ipns: &PeerId) -> Result<Option<IpfsPath>, Error>
Get an ipld path from the datastore.
sourcepub async fn put_ipns(
&self,
ipns: &PeerId,
path: &IpfsPath
) -> Result<(), Error>
pub async fn put_ipns( &self, ipns: &PeerId, path: &IpfsPath ) -> Result<(), Error>
Put an ipld path into the datastore.
sourcepub async fn remove_ipns(&self, ipns: &PeerId) -> Result<(), Error>
pub async fn remove_ipns(&self, ipns: &PeerId) -> Result<(), Error>
Remove an ipld path from the datastore.
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 insert_direct_pin(&self, cid: &Cid) -> Result<(), Error>
pub async fn insert_direct_pin(&self, cid: &Cid) -> Result<(), Error>
Inserts a direct pin for a Cid
.
sourcepub async fn insert_recursive_pin(
&self,
cid: &Cid,
refs: BoxStream<'_, Result<Cid, IpldRefsError>>
) -> Result<(), Error>
pub async fn insert_recursive_pin( &self, cid: &Cid, refs: BoxStream<'_, Result<Cid, IpldRefsError>> ) -> Result<(), Error>
Inserts a recursive pin for a Cid
.
sourcepub async fn remove_direct_pin(&self, cid: &Cid) -> Result<(), Error>
pub async fn remove_direct_pin(&self, cid: &Cid) -> Result<(), Error>
Removes a direct pin for a Cid
.
sourcepub async fn remove_recursive_pin(
&self,
cid: &Cid,
refs: BoxStream<'_, Result<Cid, IpldRefsError>>
) -> Result<(), Error>
pub async fn remove_recursive_pin( &self, cid: &Cid, refs: BoxStream<'_, Result<Cid, IpldRefsError>> ) -> Result<(), Error>
Removes a recursive pin for a Cid
.
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