Struct redb::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

Configuration builder of a redb Database.

Implementations§

source§

impl Builder

source

pub fn new() -> Self

Construct a new Builder with sensible defaults.

Defaults
source

pub fn set_write_strategy(&mut self, write_strategy: WriteStrategy) -> &mut Self

Set the write strategy of the database.

See WriteStrategy for details.

source

pub fn set_read_cache_size(&mut self, bytes: usize) -> &mut Self

Set the amount of memory (in bytes) used for caching data that has been read

This setting is ignored when calling create_mmapped()/open_mmapped()

source

pub fn set_write_cache_size(&mut self, bytes: usize) -> &mut Self

Set the amount of memory (in bytes) used for caching data that has been written

This setting is ignored when calling create_mmapped()/open_mmapped()

source

pub fn set_initial_size(&mut self, size: u64) -> &mut Self

The initial amount of usable space in bytes for the database

Databases grow dynamically, so it is generally unnecessary to set this. However, it can be used to avoid runtime overhead caused by resizing the database.

source

pub fn create(&self, path: impl AsRef<Path>) -> Result<Database, Error>

Opens the specified file as a redb database.

  • if the file does not exist, or is an empty file, a new database will be initialized in it
  • if the file is a valid redb database, it will be opened
  • otherwise this function will return an error
source

pub unsafe fn create_mmapped(
&self,
path: impl AsRef<Path>
) -> Result<Database, Error>

Opens the specified file as a redb database using the mmap backend.

  • if the file does not exist, or is an empty file, a new database will be initialized in it
  • if the file is a valid redb database, it will be opened
  • otherwise this function will return an error
Safety

Caller must ensure that the memory representing the memory-mapped file is not modified externally. In particular:

  1. the file referenced by path must not be concurrently modified by any other process
  2. an I/O failure writing back to disk must not mutate the the memory. You should consider reading this paper before assuming that your OS provides this gaurantee: https://research.cs.wisc.edu/adsl/Publications/cuttlefs-tos21.pdf
source

pub fn open(&self, path: impl AsRef<Path>) -> Result<Database, Error>

Opens an existing redb database.

source

pub unsafe fn open_mmapped(
&self,
path: impl AsRef<Path>
) -> Result<Database, Error>

Opens an existing redb database using the mmap backend.

Safety

Caller must ensure that the memory representing the memory-mapped file is not modified externally. In particular:

  1. the file referenced by path must not be concurrently modified by any other process
  2. an I/O failure writing back to disk must not mutate the the memory. You should consider reading this paper before assuming that your OS provides this gaurantee: https://research.cs.wisc.edu/adsl/Publications/cuttlefs-tos21.pdf

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.