Struct BlockBuilder

Source
pub struct BlockBuilder<S, C> { /* private fields */ }
Expand description

Generic block builder for creating blocks.

Implementations§

Source§

impl<S, C> BlockBuilder<S, C>

Source

pub fn new(store: S, codec: C) -> Self

Creates a builder for public blocks.

Source

pub fn visibility(&self) -> Visibility

Gets the visibility of the builder.

Source

pub fn store(&self) -> &S

Gets the store of the builder.

Source

pub fn codec(&self) -> &C

Gets the codec of the builder.

Source§

impl<S, C: Encrypted> BlockBuilder<S, C>

Source

pub fn new_private(store: S, codec: C) -> Self

Creates a builder for private blocks.

Source§

impl<S: ReadonlyStore, C: Decoder> BlockBuilder<S, C>

Source

pub async fn get<D: Decode<C::Codec>>(&self, cid: &Cid) -> Result<D>

Returns the decoded block with cid.

Source§

impl<S: ReadonlyStore, C: IpldDecoder> BlockBuilder<S, C>

Source

pub async fn get_ipld(&self, cid: &Cid) -> Result<Ipld>

Returns the ipld representation of a block with cid.

Source

pub async fn get_path(&self, path: &DagPath<'_>) -> Result<Ipld>

Resolves a path recursively and returns the ipld.

Source§

impl<S: Store, C: Encoder + Clone> BlockBuilder<S, C>

Source

pub fn create_batch(&self) -> Batch<C>

Creates a new batch.

Source

pub fn create_batch_with_capacity(&self, capacity: usize) -> Batch<C>

Creates a new batch with capacity.

Source

pub async fn insert<E: Encode<C::Codec>>(&self, e: &E) -> Result<Cid>

Encodes and inserts a block into the store.

Source

pub async fn insert_batch<T>(&self, batch: Batch<T>) -> Result<Cid>

Inserts a batch of blocks atomically pinning the last one.

Source§

impl<S: Store, C> BlockBuilder<S, C>

Source

pub async fn flush(&self) -> Result<()>

Flushes the store to disk.

Source

pub async fn unpin(&self, cid: &Cid) -> Result<()>

Unpins a block from the store marking it ready for garbage collection.

Source§

impl<S: MultiUserStore, C> BlockBuilder<S, C>

Source

pub async fn pin(&self, cid: &Cid, path: &Path) -> Result<()>

Pins a block in the store.

Source§

impl<S: AliasStore, C> BlockBuilder<S, C>

Source

pub async fn alias(&self, alias: &[u8], cid: &Cid) -> Result<()>

Creates an alias for a cid.

Source

pub async fn unalias(&self, alias: &[u8]) -> Result<()>

Removes an alias.

Source

pub async fn resolve(&self, alias: &[u8]) -> Result<Option<Cid>>

Resolves an alias.

Auto Trait Implementations§

§

impl<S, C> Freeze for BlockBuilder<S, C>
where S: Freeze, C: Freeze,

§

impl<S, C> RefUnwindSafe for BlockBuilder<S, C>

§

impl<S, C> Send for BlockBuilder<S, C>
where S: Send, C: Send,

§

impl<S, C> Sync for BlockBuilder<S, C>
where S: Sync, C: Sync,

§

impl<S, C> Unpin for BlockBuilder<S, C>
where S: Unpin, C: Unpin,

§

impl<S, C> UnwindSafe for BlockBuilder<S, C>
where S: UnwindSafe, C: UnwindSafe,

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<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, 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> Same for T

Source§

type Output = T

Should always be Self
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.