Struct jammdb::OpenOptions [−][src]
Options to configure how a DB
is opened.
This struct acts as a builder for a DB
and allows you to specify
the initial pagesize and number of pages you want to allocate for a new database file.
Examples
use jammdb::{DB, OpenOptions}; let db = OpenOptions::new() .pagesize(4096) .num_pages(32) .open("my.db")?; // do whatever you want with the DB
Implementations
impl OpenOptions
[src]
pub fn new() -> Self
[src]
Returns a new OpenOptions, with the default values.
pub fn pagesize(self, pagesize: u64) -> Self
[src]
Sets the pagesize for the database
By default, your OS's pagesize is used as the database's pagesize, but if the file is moved across systems with different page sizes, it is necessary to set the correct value. Trying to open an existing database with the incorrect page size will result in a panic.
Panics
Will panic if you try to set the pagesize < 1024 bytes.
pub fn num_pages(self, num_pages: usize) -> Self
[src]
Sets the number of pages to allocate for a new database file.
The default num_pages
is set to 32, so if your pagesize is 4096 bytes (4kb), then 131,072 bytes (128kb) will be allocated for the initial file.
Setting num_pages
when opening an existing database has no effect.
Panics
Since a minimum of four pages are required for the database, this function will panic if you provide a value < 4.
pub fn open<P: AsRef<Path>>(self, path: P) -> Result<DB, Error>
[src]
Opens the database with the current options.
If the file does not exist, it will initialize an empty database with a size of (num_pages * pagesize
) bytes.
If it does exist, the file is opened with both read and write permissions, and we attempt to create an
exclusive lock on the file. Getting the file lock will block until the lock
is released to prevent you from having two processes modifying the file at the same time. This lock is not foolproof though,
so it is up to the user to make sure only one process has access to the database at a time (unless it is read-only).
Errors
Will return an error if there are issues creating a new file, opening an existing file, obtaining the file lock, or creating the memory map.
Panics
Will panic if the pagesize the database is opened with is not the same as the pagesize it was created with.
Trait Implementations
impl Default for OpenOptions
[src]
Auto Trait Implementations
impl RefUnwindSafe for OpenOptions
[src]
impl Send for OpenOptions
[src]
impl Sync for OpenOptions
[src]
impl Unpin for OpenOptions
[src]
impl UnwindSafe for OpenOptions
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,