Struct grin_store::lmdb::Store

source ·
pub struct Store { /* private fields */ }
Expand description

LMDB-backed store facilitating data access and serialization. All writes are done through a Batch abstraction providing atomicity.

Implementations§

source§

impl Store

source

pub fn new( root_path: &str, env_name: Option<&str>, db_name: Option<&str>, max_readers: Option<u32> ) -> Result<Store, Error>

Create a new LMDB env under the provided directory. By default creates an environment named “lmdb”. Be aware of transactional semantics in lmdb (transactions are per environment, not per database).

source

pub fn with_version(&self, version: ProtocolVersion) -> Store

Construct a new store using a specific protocol version. Permits access to the db with legacy protocol versions for db migrations.

source

pub fn protocol_version(&self) -> ProtocolVersion

Protocol version for the store.

source

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

Opens the database environment

source

pub fn needs_resize(&self) -> Result<bool, Error>

Determines whether the environment needs a resize based on a simple percentage threshold

source

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

Increments the database size by as many ALLOC_CHUNK_SIZES to give a minimum threshold of free space

source

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

Gets a value from the db, provided its key. Deserializes the retrieved data using the provided function.

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, provided its key. Note: Creates a new read transaction so will not see any uncommitted data.

source

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

Whether the provided key exists

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 batch(&self) -> Result<Batch<'_>, Error>

Builds a new batch to be used with this store.

Auto Trait Implementations§

§

impl Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl !UnwindSafe for Store

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,