pub struct Builder { /* private fields */ }Expand description
Configuration builder of a redb Database.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn set_repair_callback(
&mut self,
callback: impl Fn(&mut RepairSession) + 'static,
) -> &mut Self
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.
Sourcepub fn set_cache_size(&mut self, bytes: usize) -> &mut Self
pub fn set_cache_size(&mut self, bytes: usize) -> &mut Self
Set the amount of memory (in bytes) used for caching data
Sourcepub fn create(&self, path: impl AsRef<Path>) -> Result<Database, DatabaseError>
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
Sourcepub fn open(&self, path: impl AsRef<Path>) -> Result<Database, DatabaseError>
pub fn open(&self, path: impl AsRef<Path>) -> Result<Database, DatabaseError>
Opens an existing redb database.
Sourcepub fn open_read_only(
&self,
path: impl AsRef<Path>,
) -> Result<ReadOnlyDatabase, DatabaseError>
pub fn open_read_only( &self, path: impl AsRef<Path>, ) -> Result<ReadOnlyDatabase, DatabaseError>
Opens an existing redb database.
If the file has been opened for writing (i.e. as a Database) DatabaseError::DatabaseAlreadyOpen
will be returned on platforms which support file locks (macOS, Windows, Linux). On other platforms,
the caller MUST avoid calling this method when the database is open for writing.
Sourcepub fn create_file(&self, file: File) -> Result<Database, DatabaseError>
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.
Sourcepub fn create_with_backend(
&self,
backend: impl StorageBackend,
) -> Result<Database, DatabaseError>
pub fn create_with_backend( &self, backend: impl StorageBackend, ) -> Result<Database, DatabaseError>
Open an existing or create a new database with the given backend.