rust_ipfs::repo

Struct Repo

Source
pub struct Repo { /* private fields */ }
Expand description

Describes a repo.

Consolidates a blockstore, a datastore and a subscription registry.

Implementations§

Source§

impl Repo

Source

pub fn new(repo_type: &mut StorageType) -> Self

Source

pub fn new_raw( block_store: Box<dyn BlockStore>, data_store: Box<dyn DataStore>, lockfile: Box<dyn Lock>, ) -> Self

Source

pub fn new_fs(path: impl AsRef<Path>) -> Self

Source

pub fn new_memory() -> Self

Source

pub fn set_max_storage_size(&self, size: usize)

Source

pub fn max_storage_size(&self) -> usize

Source

pub async fn migrate(&self, repo: &Self) -> Result<(), Error>

Source

pub fn shutdown(&self)

Shutdowns the repo, cancelling any pending subscriptions; Likely going away after some refactoring, see notes on crate::Ipfs::exit_daemon.

Source

pub fn is_online(&self) -> bool

Source

pub async fn init(&self) -> Result<(), Error>

Source

pub fn put_block<'a>(&self, block: &'a Block) -> RepoPutBlock<'a>

Puts a block into the block store.

Source

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.

Source

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.

Source

pub async fn get_blocks_size( &self, cids: &[Cid], ) -> Result<Option<usize>, Error>

Get the size of listed blocks

Source

pub async fn get_total_size(&self) -> Result<usize, Error>

Get the total size of the block store

Source

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.

Source

pub async fn contains<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>

Check to determine if blockstore contain a block

Source

pub async fn list_blocks(&self) -> BoxStream<'static, Cid>

Lists the blocks in the blockstore.

Source

pub async fn remove_block<C: Borrow<Cid>>( &self, cid: C, recursive: bool, ) -> Result<Vec<Cid>, Error>

Remove block from the block store.

Source

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.

Source

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.

Source

pub fn fetch<C: Borrow<Cid>>(&self, cid: C) -> RepoFetch

Source

pub async fn is_pinned<C: Borrow<Cid>>(&self, cid: C) -> Result<bool, Error>

Checks if a Cid is pinned.

Source

pub async fn list_pins( &self, mode: impl Into<Option<PinMode>>, ) -> BoxStream<'static, Result<(Cid, PinMode), Error>>

Source

pub async fn query_pins( &self, cids: Vec<Cid>, requirement: impl Into<Option<PinMode>>, ) -> Result<Vec<(Cid, PinKind<Cid>)>, Error>

Source§

impl Repo

Source

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

Source

pub fn data_store(&self) -> &dyn DataStore

Trait Implementations§

Source§

impl Clone for Repo

Source§

fn clone(&self) -> Repo

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Repo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Repo> for IpldDag

Source§

fn from(repo: Repo) -> Self

Converts to this type from the input type.

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<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> TimeoutExt for T

Source§

fn timeout(self, duration: Duration) -> Timeout<Self>

Requires a Future or Stream to complete before the specific duration has elapsed. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more