Struct Transaction

Source
pub struct Transaction<'a, S> { /* private fields */ }

Implementations§

Source§

impl<'a, S> Transaction<'a, S>

Source

pub fn alias<'b>( &mut self, name: impl Into<Cow<'b, [u8]>>, link: Option<&'b Cid>, ) -> Result<()>

Set or delete an alias

Source

pub fn reverse_alias(&mut self, cid: &Cid) -> Result<Option<HashSet<Vec<u8>>>>

Returns the aliases referencing a cid.

Source

pub fn resolve<'b>( &mut self, name: impl Into<Cow<'b, [u8]>>, ) -> Result<Option<Cid>>

Resolves an alias to a cid.

Source

pub fn temp_pin(&mut self) -> TempPin

Get a temporary pin for safely adding blocks to the store

Source

pub fn extend_temp_pin(&mut self, pin: &mut TempPin, link: &Cid) -> Result<()>

Extend temp pin with an additional cid

Source

pub fn has_cid(&mut self, cid: &Cid) -> Result<bool>

Checks if the store knows about the cid.

Note that this does not necessarily mean that the store has the data for the cid.

Source

pub fn has_block(&mut self, cid: &Cid) -> Result<bool>

Checks if the store has the data for a cid

Source

pub fn get_known_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>

Get all cids that the store knows about

Source

pub fn get_block_cids<C: FromIterator<Cid>>(&mut self) -> Result<C>

Get all cids for which the store has blocks

Source

pub fn get_descendants<C: FromIterator<Cid>>(&mut self, cid: &Cid) -> Result<C>

Get descendants of a cid

Source

pub fn get_missing_blocks<C: FromIterator<Cid>>( &mut self, cid: &Cid, ) -> Result<C>

Given a root of a dag, gives all cids which we do not have data for.

Source

pub fn aliases<C: FromIterator<(Vec<u8>, Cid)>>(&mut self) -> Result<C>

list all aliases

Source

pub fn put_block( &mut self, block: Block<S>, pin: Option<&mut TempPin>, ) -> Result<()>

Put a block. This will only be completed once the transaction is successfully committed

Source

pub fn get_block(&mut self, cid: &Cid) -> Result<Option<Vec<u8>>>

Get a block

Source

pub fn get_store_stats(&mut self) -> Result<StoreStats>

Get the stats for the store.

The stats are kept up to date, so this is fast.

Source

pub fn commit(self) -> Result<()>

Commit and consume the transaction. Default is to not commit.

Auto Trait Implementations§

§

impl<'a, S> Freeze for Transaction<'a, S>

§

impl<'a, S> !RefUnwindSafe for Transaction<'a, S>

§

impl<'a, S> Send for Transaction<'a, S>
where S: Send,

§

impl<'a, S> !Sync for Transaction<'a, S>

§

impl<'a, S> Unpin for Transaction<'a, S>
where S: Unpin,

§

impl<'a, S> !UnwindSafe for Transaction<'a, S>

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> 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> References<RawCodec> for T

Source§

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

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