Skip to main content

DatabaseBuilder

Struct DatabaseBuilder 

Source
pub struct DatabaseBuilder<O: Openable> { /* private fields */ }
Expand description

Database builder

Implementations§

Source§

impl<O: Openable> Builder<O>

Source

pub fn open(self) -> Result<O>

Opens the database, creating it if it does not exist.

§Errors

Errors if an I/O error occurred, or if the database can not be opened.

Source

pub fn journal_compression(self, comp: CompressionType) -> Self

Sets the compression type to use for large values that are written into the journal file.

Source

pub fn manual_journal_persist(self, flag: bool) -> Self

If false, write batches or transactions automatically flush data to the operating system.

Default = false

Set to true to handle persistence manually, e.g. manually using PersistMode::SyncData for ACID transactions.

Source

pub fn worker_threads(self, n: usize) -> Self

Sets the number of worker threads.

Default = min(# CPU cores, 4)

§Panics

Panics, if below 1.

Source

pub fn max_cached_files(self, n: Option<usize>) -> Self

Sets the upper limit for cached file descriptors.

§Note

Setting to None is currently not supported.

§Panics

Panics if n < 10 or None.

Source

pub fn cache_size(self, size_bytes: u64) -> Self

Sets the cache capacity in bytes.

It is recommended to configure the block cache capacity to be ~20-25% of the available memory - or more if the data set fully fits into memory.

Source

pub fn max_journaling_size(self, bytes: u64) -> Self

Maximum size of all journals in bytes.

Default = 512 MiB

§Panics

Panics if < 64 MiB.

Same as max_total_wal_size in RocksDB.

Source

pub fn temporary(self, flag: bool) -> Self

Sets the Database to clean upon drop.

§Examples
let db = Database::builder(&folder).temporary(true).open()?;

assert!(folder.try_exists()?);
drop(db);
assert!(!folder.try_exists()?);

Auto Trait Implementations§

§

impl<O> Freeze for Builder<O>

§

impl<O> RefUnwindSafe for Builder<O>
where O: RefUnwindSafe,

§

impl<O> Send for Builder<O>
where O: Send,

§

impl<O> Sync for Builder<O>
where O: Sync,

§

impl<O> Unpin for Builder<O>
where O: Unpin,

§

impl<O> UnwindSafe for Builder<O>
where O: 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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.