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
  • cache_size_bytes: 1GiB
source

pub fn set_repair_callback( &mut self, callback: impl Fn(&mut RepairSession) + 'static, ) -> &mut Self

Set a callback which will be invoked periodically in the event that the database file needs to be repaired.

The RepairSession argument can be used to control the repair process.

If the database file needs repair, the callback will be invoked at least once. There is no upper limit on the number of times it may be called.

source

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

Set the amount of memory (in bytes) used for caching data

source

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

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 fn open(&self, path: impl AsRef<Path>) -> Result<Database, DatabaseError>

Opens an existing redb database.

source

pub fn create_file(&self, file: File) -> Result<Database, DatabaseError>

Open an existing or create a new database in the given file.

The file must be empty or contain a valid database.

source

pub fn create_with_backend( &self, backend: impl StorageBackend, ) -> Result<Database, DatabaseError>

Open an existing or create a new database with the given backend.

Auto Trait Implementations§

§

impl Freeze for Builder

§

impl !RefUnwindSafe for Builder

§

impl !Send for Builder

§

impl !Sync for Builder

§

impl Unpin for Builder

§

impl !UnwindSafe for Builder

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, 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.