pub struct Builder { /* private fields */ }
Implementations§
source§impl Builder
impl Builder
pub fn new() -> Self
pub fn set_write_strategy(&mut self, write_strategy: WriteStrategy) -> &mut Self
sourcepub fn set_read_cache_size(&mut self, bytes: usize) -> &mut Self
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()
sourcepub fn set_write_cache_size(&mut self, bytes: usize) -> &mut Self
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()
sourcepub fn set_initial_size(&mut self, size: u64) -> &mut Self
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.
sourcepub fn create(&self, path: impl AsRef<Path>) -> Result<Database, Error>
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
sourcepub unsafe fn create_mmapped(
&self,
path: impl AsRef<Path>
) -> Result<Database, Error>
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:
- the file referenced by
path
must not be concurrently modified by any other process - 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
sourcepub fn open(&self, path: impl AsRef<Path>) -> Result<Database, Error>
pub fn open(&self, path: impl AsRef<Path>) -> Result<Database, Error>
Opens an existing redb database.
sourcepub unsafe fn open_mmapped(
&self,
path: impl AsRef<Path>
) -> Result<Database, Error>
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:
- the file referenced by
path
must not be concurrently modified by any other process - 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