pub struct FileHandle {
pub path: PathBuf,
pub num_pages: u64,
pub page_size: usize,
pub free_space_manager: Option<Arc<FreeSpaceManager>>,
}Expand description
A file handle mapping logical page numbers to file offsets.
Fields§
§path: PathBufPath to the database file.
num_pages: u64Number of pages currently in the file.
page_size: usizePage size in bytes.
free_space_manager: Option<Arc<FreeSpaceManager>>Free space manager for reusing pages.
Implementations§
Source§impl FileHandle
impl FileHandle
pub fn new(path: PathBuf, page_size: usize) -> Self
pub fn with_free_space_manager(self, fsm: Arc<FreeSpaceManager>) -> Self
Sourcepub fn page_offset(&self, page_num: PageNum) -> u64
pub fn page_offset(&self, page_num: PageNum) -> u64
Get the file offset for a given page number.
Sourcepub fn allocate_page(&mut self) -> PageNum
pub fn allocate_page(&mut self) -> PageNum
Allocate a new page (extend the file or reuse from FSM).
Sourcepub fn extend_file(&mut self, num_pages: u64) -> Result<PageNum>
pub fn extend_file(&mut self, num_pages: u64) -> Result<PageNum>
Extend the file by num_pages pages, writing zero-filled data.
Returns the starting page number of the newly extended region.
Trait Implementations§
Source§impl Clone for FileHandle
impl Clone for FileHandle
Source§fn clone(&self) -> FileHandle
fn clone(&self) -> FileHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FileHandle
impl RefUnwindSafe for FileHandle
impl Send for FileHandle
impl Sync for FileHandle
impl Unpin for FileHandle
impl UnsafeUnpin for FileHandle
impl UnwindSafe for FileHandle
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more