Struct heed::DatabaseOpenOptions

source ·
pub struct DatabaseOpenOptions<'e, 'n, KC, DC, C = DefaultComparator> { /* private fields */ }
Expand description

Options and flags which can be used to configure how a Database is opened.

§Examples

Opening a file to read:

use heed::types::*;
use heed::byteorder::BigEndian;

type BEI64 = I64<BigEndian>;

// Imagine you have an optional name
let conditional_name = Some("big-endian-iter");

let mut wtxn = env.write_txn()?;
let mut options = env.database_options().types::<BEI64, Unit>();
if let Some(name) = conditional_name {
   options.name(name);
}
let db = options.create(&mut wtxn)?;

db.put(&mut wtxn, &68, &())?;
db.put(&mut wtxn, &35, &())?;
db.put(&mut wtxn, &0, &())?;
db.put(&mut wtxn, &42, &())?;

wtxn.commit()?;

Implementations§

source§

impl<'e> DatabaseOpenOptions<'e, 'static, Unspecified, Unspecified>

source

pub fn new(env: &'e Env) -> Self

Create an options struct to open/create a database with specific flags.

source§

impl<'e, 'n, KC, DC, C> DatabaseOpenOptions<'e, 'n, KC, DC, C>

source

pub fn types<NKC, NDC>(self) -> DatabaseOpenOptions<'e, 'n, NKC, NDC>

Change the type of the database.

The default types are Unspecified and require a call to Database::remap_types to use the Database.

source

pub fn key_comparator<NC>(self) -> DatabaseOpenOptions<'e, 'n, KC, DC, NC>

Change the customized key compare function of the database.

By default no customized compare function will be set when opening a database.

source

pub fn name(&mut self, name: &'n str) -> &mut Self

Change the name of the database.

By default the database is unnamed and there only is a single unnamed database.

source

pub fn flags(&mut self, flags: DatabaseFlags) -> &mut Self

Specify the set of flags used to open the database.

source

pub fn open(&self, rtxn: &RoTxn<'_>) -> Result<Option<Database<KC, DC, C>>>
where KC: 'static, DC: 'static, C: Comparator + 'static,

Opens a typed database that already exists in this environment.

If the database was previously opened in this program run, types will be checked.

§Important Information

LMDB has an important restriction on the unnamed database when named ones are opened. The names of the named databases are stored as keys in the unnamed one and are immutable, and these keys can only be read and not written.

§LMDB read-only access of existing database

In the case of accessing a database in a read-only manner from another process where you wrote, you might need to manually call RoTxn::commit to get metadata and the database handles opened and shared with the global Env handle.

If not done, you might raise Io(Os { code: 22, kind: InvalidInput, message: "Invalid argument" }) known as EINVAL.

source

pub fn create(&self, wtxn: &mut RwTxn<'_>) -> Result<Database<KC, DC, C>>
where KC: 'static, DC: 'static, C: Comparator + 'static,

Creates a typed database that can already exist in this environment.

If the database was previously opened in this program run, types will be checked.

§Important Information

LMDB has an important restriction on the unnamed database when named ones are opened. The names of the named databases are stored as keys in the unnamed one and are immutable, and these keys can only be read and not written.

Trait Implementations§

source§

impl<KC, DC, C> Clone for DatabaseOpenOptions<'_, '_, KC, DC, C>

source§

fn clone(&self) -> Self

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<'e, 'n, KC: Debug, DC: Debug, C: Debug> Debug for DatabaseOpenOptions<'e, 'n, KC, DC, C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<KC, DC, C> Copy for DatabaseOpenOptions<'_, '_, KC, DC, C>

Auto Trait Implementations§

§

impl<'e, 'n, KC, DC, C> Freeze for DatabaseOpenOptions<'e, 'n, KC, DC, C>

§

impl<'e, 'n, KC, DC, C> RefUnwindSafe for DatabaseOpenOptions<'e, 'n, KC, DC, C>

§

impl<'e, 'n, KC, DC, C> Send for DatabaseOpenOptions<'e, 'n, KC, DC, C>
where KC: Send, DC: Send, C: Send,

§

impl<'e, 'n, KC, DC, C> Sync for DatabaseOpenOptions<'e, 'n, KC, DC, C>
where KC: Sync, DC: Sync, C: Sync,

§

impl<'e, 'n, KC, DC, C> Unpin for DatabaseOpenOptions<'e, 'n, KC, DC, C>
where KC: Unpin, DC: Unpin, C: Unpin,

§

impl<'e, 'n, KC, DC, C> UnwindSafe for DatabaseOpenOptions<'e, 'n, KC, DC, C>
where KC: UnwindSafe, DC: 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

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

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.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes