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>
impl<'e> DatabaseOpenOptions<'e, 'static, Unspecified, Unspecified>
Source§impl<'e, 'n, KC, DC, C> DatabaseOpenOptions<'e, 'n, KC, DC, C>
impl<'e, 'n, KC, DC, C> DatabaseOpenOptions<'e, 'n, KC, DC, C>
Sourcepub fn types<NKC, NDC>(self) -> DatabaseOpenOptions<'e, 'n, NKC, NDC>
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
.
Sourcepub fn key_comparator<NC>(self) -> DatabaseOpenOptions<'e, 'n, KC, DC, NC>
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.
Sourcepub fn name(&mut self, name: &'n str) -> &mut Self
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.
Sourcepub fn flags(&mut self, flags: DatabaseFlags) -> &mut Self
pub fn flags(&mut self, flags: DatabaseFlags) -> &mut Self
Specify the set of flags used to open the database.
Sourcepub fn open(&self, rtxn: &RoTxn<'_>) -> Result<Option<Database<KC, DC, C>>>where
KC: 'static,
DC: 'static,
C: Comparator + 'static,
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
.
Sourcepub fn create(&self, wtxn: &mut RwTxn<'_>) -> Result<Database<KC, DC, C>>where
KC: 'static,
DC: 'static,
C: Comparator + 'static,
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>
impl<KC, DC, C> Clone for DatabaseOpenOptions<'_, '_, KC, DC, C>
Source§impl<'e, 'n, KC: Debug, DC: Debug, C: Debug> Debug for DatabaseOpenOptions<'e, 'n, KC, DC, C>
impl<'e, 'n, KC: Debug, DC: Debug, C: Debug> Debug for DatabaseOpenOptions<'e, 'n, KC, DC, C>
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>
impl<'e, 'n, KC, DC, C> Sync for DatabaseOpenOptions<'e, 'n, KC, DC, C>
impl<'e, 'n, KC, DC, C> Unpin for DatabaseOpenOptions<'e, 'n, KC, DC, C>
impl<'e, 'n, KC, DC, C> UnwindSafe for DatabaseOpenOptions<'e, 'n, KC, DC, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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