Struct DBBuilder

Source
pub struct DBBuilder { /* private fields */ }
Expand description

Struct to construct database

§Example

use nut::DBBuilder;

let db = DBBuilder::new("./test.db").read_only(true).build();

Implementations§

Source§

impl DBBuilder

Source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Creates new Builder, path required.

Source

pub fn path<P: AsRef<Path>>(self, path: P) -> Self

Path to db file

Source

pub fn no_grow_sync(self, v: bool) -> Self

Sets the DB.no_grow_sync flag before memory mapping the file.

Default: false

Source

pub fn read_only(self, v: bool) -> Self

Open database in read-only mode.

If database opened in read only mode file will be locked shared and exclusively otherwise.

Default: false

Source

pub fn initial_mmap_size(self, v: usize) -> Self

Initial mmap size of the database

in bytes. Read transactions won’t block write transaction

if the initial_mmap_size is large enough to hold database mmap size. (See DB.begin for more information)

If = 0, the initial map size is size of first 4 pages.

If initial_mmap_size is smaller than the previous database size, it takes no effect.

Default: 0 (mmap will be equal to 4 page sizes)

Source

pub fn autoremove(self, v: bool) -> Self

Defines whether db file will be removed after db close

Default: false

Source

pub fn checkmode(self, v: CheckMode) -> Self

Defines database checking mode

Default: CheckMode::No

Source

pub fn batch_delay(self, v: Duration) -> Self

Defines batch delay time

Default: 10 seconds

Source

pub fn batch_size(self, v: usize) -> Self

Defines max batch size. If size equals 0, size is unlimited

Default: 1000

Source

pub fn page_size(self, v: usize) -> Self

Defines page size to initialize db with. When opening existing db its page size will be used.

Default: page size defined by OS

Source

pub fn build(self) -> Result<DB, Error>

Builds and returns DB instance

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.