pub struct EnvBuilder { /* private fields */ }
Expand description
Constructs environment with settigs which couldn’t be
changed after opening. By default it tries to create
corresponding dir if it doesn’t exist, use autocreate_dir()
to override that behavior
Implementations§
Source§impl EnvBuilder
impl EnvBuilder
Sourcepub fn new() -> EnvBuilder
pub fn new() -> EnvBuilder
Examples found in repository?
examples/simple.rs (line 6)
5fn main() {
6 let env = EnvBuilder::new().open("test-lmdb", 0o777).unwrap();
7
8 let db_handle = env.get_default_db(DbFlags::empty()).unwrap();
9 let txn = env.new_transaction().unwrap();
10 {
11 let db = txn.bind(&db_handle); // get a database bound to this transaction
12
13 let pairs = vec![("Albert", "Einstein",),
14 ("Joe", "Smith",),
15 ("Jack", "Daniels")];
16
17 for &(name, surname) in pairs.iter() {
18 db.set(&surname, &name).unwrap();
19 }
20 }
21
22 // Note: `commit` is choosen to be explicit as
23 // in case of failure it is responsibility of
24 // the client to handle the error
25 match txn.commit() {
26 Err(_) => panic!("failed to commit!"),
27 Ok(_) => ()
28 }
29
30 let reader = env.get_reader().unwrap();
31 let db = reader.bind(&db_handle);
32 let name = db.get::<&str>(&"Smith").unwrap();
33 println!("It's {} Smith", name);
34}
Sourcepub fn flags(self, flags: EnvCreateFlags) -> EnvBuilder
pub fn flags(self, flags: EnvCreateFlags) -> EnvBuilder
Sets environment flags
Sourcepub fn max_readers(self, max_readers: usize) -> EnvBuilder
pub fn max_readers(self, max_readers: usize) -> EnvBuilder
Sets max concurrent readers operating on environment
Sourcepub fn max_dbs(self, max_dbs: usize) -> EnvBuilder
pub fn max_dbs(self, max_dbs: usize) -> EnvBuilder
Set max number of databases
Sourcepub fn map_size(self, map_size: u64) -> EnvBuilder
pub fn map_size(self, map_size: u64) -> EnvBuilder
Sets max environment size, i.e. size in memory/disk of all data
Sourcepub fn autocreate_dir(self, autocreate_dir: bool) -> EnvBuilder
pub fn autocreate_dir(self, autocreate_dir: bool) -> EnvBuilder
Sets whetever lmdb-rs
should try to autocreate dir with default
permissions on opening (default is true)
Sourcepub fn open<P: AsRef<Path>>(self, path: P, perms: u32) -> MdbResult<Environment>
pub fn open<P: AsRef<Path>>(self, path: P, perms: u32) -> MdbResult<Environment>
Opens environment in specified path
Examples found in repository?
examples/simple.rs (line 6)
5fn main() {
6 let env = EnvBuilder::new().open("test-lmdb", 0o777).unwrap();
7
8 let db_handle = env.get_default_db(DbFlags::empty()).unwrap();
9 let txn = env.new_transaction().unwrap();
10 {
11 let db = txn.bind(&db_handle); // get a database bound to this transaction
12
13 let pairs = vec![("Albert", "Einstein",),
14 ("Joe", "Smith",),
15 ("Jack", "Daniels")];
16
17 for &(name, surname) in pairs.iter() {
18 db.set(&surname, &name).unwrap();
19 }
20 }
21
22 // Note: `commit` is choosen to be explicit as
23 // in case of failure it is responsibility of
24 // the client to handle the error
25 match txn.commit() {
26 Err(_) => panic!("failed to commit!"),
27 Ok(_) => ()
28 }
29
30 let reader = env.get_reader().unwrap();
31 let db = reader.bind(&db_handle);
32 let name = db.get::<&str>(&"Smith").unwrap();
33 println!("It's {} Smith", name);
34}
Trait Implementations§
Source§impl Clone for EnvBuilder
impl Clone for EnvBuilder
Source§fn clone(&self) -> EnvBuilder
fn clone(&self) -> EnvBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for EnvBuilder
impl Debug for EnvBuilder
Source§impl Default for EnvBuilder
impl Default for EnvBuilder
impl Copy for EnvBuilder
Auto Trait Implementations§
impl Freeze for EnvBuilder
impl RefUnwindSafe for EnvBuilder
impl Send for EnvBuilder
impl Sync for EnvBuilder
impl Unpin for EnvBuilder
impl UnwindSafe for EnvBuilder
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
Mutably borrows from an owned value. Read more