heed

Struct 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 u8)

🔬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