Struct rust_ipfs::repo::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 StoragePath, duration: Option<Duration>) -> 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>, duration: impl Into<Option<Duration>> ) -> Self

source

pub fn new_memory(duration: impl Into<Option<Duration>>) -> 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 async fn open(&self) -> Result<(), Error>

source

pub async fn put_block(&self, block: Block) -> Result<(Cid, BlockPut), Error>

Puts a block into the block store.

source

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.

source

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.

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(&self, cid: &Cid) -> Result<Option<Block>, Error>

Retrieves a block from the block store if it’s available locally.

source

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

Check to determine if blockstore contain a block

source

pub async fn list_blocks(&self) -> Result<Vec<Cid>, Error>

Lists the blocks in the blockstore.

source

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

Remove block from the block store.

source

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.

source

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.

source

pub async fn insert_pin( &self, cid: &Cid, recursive: bool, local_only: bool ) -> Result<(), Error>

Pins a given Cid recursively or directly (non-recursively).

source

pub async fn cleanup(&self) -> Result<Vec<Cid>, Error>

Function to perform a basic cleanup of unpinned blocks

source

pub async fn is_pinned(&self, cid: &Cid) -> 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 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.
source§

impl Store for Repo

source§

fn get_size<'life0, 'life1, 'async_trait>( &'life0 self, cid: &'life1 Cid ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, cid: &'life1 Cid ) -> Pin<Box<dyn Future<Output = Result<Block>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn has<'life0, 'life1, 'async_trait>( &'life0 self, cid: &'life1 Cid ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Auto Trait Implementations§

§

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
§

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

§

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

§

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

§

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> 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> References<RawCodec> for T

§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>
where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
§

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

§

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