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 StorageType) -> 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>) -> Self
pub fn new_memory() -> 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>
Sourcepub fn put_block<'a>(&self, block: &'a Block) -> RepoPutBlock<'a>
pub fn put_block<'a>(&self, block: &'a Block) -> RepoPutBlock<'a>
Puts a block into the block store.
Sourcepub fn get_block<C: Borrow<Cid>>(&self, cid: C) -> RepoGetBlock ⓘ
pub fn get_block<C: Borrow<Cid>>(&self, cid: C) -> RepoGetBlock ⓘ
Retrives a block from the block store, or starts fetching it from the network and awaits until it has been fetched.
Sourcepub fn get_blocks(
&self,
cids: impl IntoIterator<Item = impl Borrow<Cid>>,
) -> RepoGetBlocks
pub fn get_blocks( &self, cids: impl IntoIterator<Item = impl Borrow<Cid>>, ) -> RepoGetBlocks
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<C: Borrow<Cid>>(
&self,
cid: C,
) -> Result<Option<Block>, Error>
pub async fn get_block_now<C: Borrow<Cid>>( &self, cid: C, ) -> Result<Option<Block>, Error>
Retrieves a block from the block store if it’s available locally.
Sourcepub async fn contains<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>
pub async fn contains<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>
Check to determine if blockstore contain a block
Sourcepub async fn list_blocks(&self) -> BoxStream<'static, Cid>
pub async fn list_blocks(&self) -> BoxStream<'static, Cid>
Lists the blocks in the blockstore.
Sourcepub async fn remove_block<C: Borrow<Cid>>(
&self,
cid: C,
recursive: bool,
) -> Result<Vec<Cid>, Error>
pub async fn remove_block<C: Borrow<Cid>>( &self, cid: C, recursive: bool, ) -> Result<Vec<Cid>, Error>
Remove block from the block store.
Sourcepub fn pin<C: Borrow<Cid>>(&self, cid: C) -> RepoInsertPin
pub fn pin<C: Borrow<Cid>>(&self, cid: C) -> 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<C: Borrow<Cid>>(&self, cid: C) -> RepoRemovePin
pub fn remove_pin<C: Borrow<Cid>>(&self, cid: C) -> 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.
pub fn fetch<C: Borrow<Cid>>(&self, cid: C) -> RepoFetch
Sourcepub async fn is_pinned<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>
pub async fn is_pinned<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>
Checks if a Cid
is pinned.
pub async fn list_pins( &self, mode: impl Into<Option<PinMode>>, ) -> BoxStream<'static, Result<(Cid, PinMode), Error>>
pub async fn query_pins( &self, cids: Vec<Cid>, requirement: impl Into<Option<PinMode>>, ) -> Result<Vec<(Cid, PinKind<Cid>)>, Error>
Source§impl Repo
impl Repo
Sourcepub async fn gc_guard(&self) -> GCGuard<'_>
pub async fn gc_guard(&self) -> GCGuard<'_>
Hold a guard to prevent GC from running until this guard has dropped Note: Until this guard drops, the GC task, if enabled, would not perform any cleanup. If the GC task is running, this guard will await until GC finishes
pub fn data_store(&self) -> &dyn DataStore
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Repo
impl !RefUnwindSafe for Repo
impl Send for Repo
impl Sync for Repo
impl Unpin for Repo
impl !UnwindSafe for Repo
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more