Pager

Struct Pager 

Source
pub struct Pager {
    pub meta: IndexMeta,
    /* private fields */
}

Fields§

§meta: IndexMeta

Implementations§

Source§

impl Pager

Source

pub fn create(path: &Path) -> IsamResult<Self>

Create a brand-new index file. Writes page 0 (metadata) and allocates page 1 as an empty leaf (the initial root).

Source

pub fn open(path: &Path) -> IsamResult<Self>

Open an existing index file and read its metadata header.

Source

pub fn read_page(&mut self, id: u32) -> IsamResult<Vec<u8>>

Read page id into a fresh PAGE_SIZE-byte buffer.

Source

pub fn write_page(&mut self, id: u32, data: &[u8]) -> IsamResult<()>

Write data (must be exactly PAGE_SIZE bytes) to page id.

Source

pub fn alloc_page(&mut self) -> IsamResult<u32>

Allocate a new blank page at the end of the file and return its id.

Source

pub fn flush_meta(&mut self) -> IsamResult<()>

Write the current self.meta back to page 0.

Source

pub fn flush(&mut self) -> IsamResult<()>

Flush OS write buffers.

Source

pub fn fsync(&mut self) -> IsamResult<()>

Flush and fsync for durability.

Source

pub fn empty_leaf_page() -> Vec<u8>

Returns an empty leaf page (all zeros except the page_type byte).

Source

pub fn empty_internal_page() -> Vec<u8>

Returns an empty internal page.

Auto Trait Implementations§

§

impl Freeze for Pager

§

impl RefUnwindSafe for Pager

§

impl Send for Pager

§

impl Sync for Pager

§

impl Unpin for Pager

§

impl UnwindSafe for Pager

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.