redb

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