pub struct PageFileOptions { /* private fields */ }Expand description
Options for opening a PageFile.
Build with PageFileOptions::new, adjust, then open.
The defaults are a 4 KiB page size, Direct I/O enabled, and create-if-absent.
§Examples
use page_db::{PageFileOptions, PageSize};
let file = PageFileOptions::new()
.page_size(PageSize::new(8192)?)
.direct_io(false) // buffered, e.g. on a filesystem without O_DIRECT
.open(&path)?;
assert_eq!(file.page_size(), 8192);Implementations§
Source§impl PageFileOptions
impl PageFileOptions
Sourcepub fn page_size(self, page_size: PageSize) -> Self
pub fn page_size(self, page_size: PageSize) -> Self
Set the page size. Every page in the file is this size; it is fixed for the life of the file and the caller is responsible for reopening with the same size.
Sourcepub fn direct_io(self, enabled: bool) -> Self
pub fn direct_io(self, enabled: bool) -> Self
Enable or disable Direct I/O (cache-bypass).
Direct I/O is the default and the point of this crate. Disable it for a
filesystem that does not support it (some network and overlay
filesystems reject O_DIRECT); durability via PageFile::sync is
unaffected, only the page cache is.
Sourcepub fn create(self, create: bool) -> Self
pub fn create(self, create: bool) -> Self
Create the file if it does not exist (the default). When false, opening
a missing file is an error.
Sourcepub fn open<P: AsRef<Path>>(self, path: P) -> PageResult<PageFile>
pub fn open<P: AsRef<Path>>(self, path: P) -> PageResult<PageFile>
Open the page file at path with these options.
§Errors
Returns PageError::Io if the file cannot be opened (including a
filesystem that rejects Direct I/O, surfaced as the OS error).
Trait Implementations§
Source§impl Clone for PageFileOptions
impl Clone for PageFileOptions
Source§fn clone(&self) -> PageFileOptions
fn clone(&self) -> PageFileOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more