Struct swap::file::FilePageStates

source ·
struct FilePageStates {
    first_idx_file_freed: Option<usize>,
    states: Vec<FilePageState>,
}

Fields§

§first_idx_file_freed: Option<usize>

Freed pages on the swap file are managed in a free list. first_freed_idx_file points to the first page index in the list.

§states: Vec<FilePageState>

Implementations§

source§

impl FilePageStates

source

fn new(capacity: usize) -> Self

source

fn len(&self) -> usize

source

fn free(&mut self, idx_file: usize)

Free a page on swap file.

source

fn allocate(&mut self, idx_page: usize) -> usize

Allocates a file page on the swap file.

This returns the index of the allocated file page.

This reuses freed file pages first. If the free list is empty, this allocates new pages in the file.

source

fn find_present_pages_range( &self, idx_file: usize, page_states: &[PageState], max_pages: usize, consecutive: bool ) -> Option<(Range<usize>, usize)>

Find the index range of file pages that are all present.

This returns the pair of range of file page indexes and the index of the corresponding first page.

Returns None if no pages after idx_file are present.

§Arguments
  • idx_file - The first index to start searching from.
  • page_states - The page states
  • max_pages - The maximum number of pages to search.
  • consecutive - If true, the pages must have consecutive idx_page values.

Trait Implementations§

source§

impl Debug for FilePageStates

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.