Struct grin_store::lmdb::Batch

source ·
pub struct Batch<'a> { /* private fields */ }
Expand description

Batch to write multiple Writeables to db in an atomic manner.

Implementations§

source§

impl<'a> Batch<'a>

source

pub fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error>

Writes a single key/value pair to the db

source

pub fn put_ser<W: Writeable>(&self, key: &[u8], value: &W) -> Result<(), Error>

Writes a single key and its Writeable value to the db. Encapsulates serialization using the (default) version configured on the store instance.

source

pub fn protocol_version(&self) -> ProtocolVersion

Protocol version used by this batch.

source

pub fn put_ser_with_version<W: Writeable>( &self, key: &[u8], value: &W, version: ProtocolVersion ) -> Result<(), Error>

Writes a single key and its Writeable value to the db. Encapsulates serialization using the specified protocol version.

source

pub fn get_with<F, T>( &self, key: &[u8], deserialize: F ) -> Result<Option<T>, Error>
where F: Fn(&[u8], &[u8]) -> Result<T, Error>,

Low-level access for retrieving data by key. Takes a function for flexible deserialization.

source

pub fn exists(&self, key: &[u8]) -> Result<bool, Error>

Whether the provided key exists. This is in the context of the current write transaction.

source

pub fn iter<F, T>( &self, prefix: &[u8], deserialize: F ) -> Result<PrefixIterator<F, T>, Error>
where F: Fn(&[u8], &[u8]) -> Result<T, Error>,

Produces an iterator from the provided key prefix.

source

pub fn get_ser<T: Readable>( &self, key: &[u8], deser_mode: Option<DeserializationMode> ) -> Result<Option<T>, Error>

Gets a Readable value from the db by provided key and provided deserialization strategy.

source

pub fn delete(&self, key: &[u8]) -> Result<(), Error>

Deletes a key/value pair from the db

source

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

Writes the batch to db

source

pub fn child(&mut self) -> Result<Batch<'_>, Error>

Creates a child of this batch. It will be merged with its parent on commit, abandoned otherwise.

Auto Trait Implementations§

§

impl<'a> !Freeze for Batch<'a>

§

impl<'a> !RefUnwindSafe for Batch<'a>

§

impl<'a> !Send for Batch<'a>

§

impl<'a> !Sync for Batch<'a>

§

impl<'a> Unpin for Batch<'a>

§

impl<'a> !UnwindSafe for Batch<'a>

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> SafeBorrow<T> for T
where T: ?Sized,

source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
source§

impl<T> Same for T

§

type Output = T

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

impl<T> UnsafeAny for T
where T: Any,