Slot

Struct Slot 

Source
pub struct Slot {
    pub file: RegularFile,
    pub fba: FileBlockNumber,
    pub page: Page,
    pub writeback_size: Option<usize>,
}
Expand description

A single entry in the page cache.

A Slot corresponds to one file block stored in memory.

Fields§

§file: RegularFile

The file this slot belongs to.

§fba: FileBlockNumber

The file block number this slot represents.

§page: Page

The backing page containing the block’s data.

§writeback_size: Option<usize>

Size to be write-backed if dirtied. If the slot is clean, this will be None.

Implementations§

Source§

impl Slot

Source

pub fn new(file: RegularFile, fba: FileBlockNumber, page: Page) -> Self

Create a new slot for the given file, block, and backing page.

By default, the slot is clean (i.e., writeback_size is None).

Source

pub fn read_page(&self, buf: &mut [u8; 4096])

Copy the page contents into the provided buffer.

The buffer must be exactly 4096 bytes long, representing a full page. This method does not trigger I/O.

Source

pub fn write_page(&mut self, buf: &[u8; 4096], min_size: usize)

Update the page contents from the provided buffer.

Marks the slot as dirty with a write-back of at least min_size bytes. The buffer must be exactly 4096 bytes long.

Source

pub fn writeback(&mut self) -> Result<(), KernelError>

Write back the dirty portion of the page to the underlying file.

  • If writeback_size is Some(size), representing slot is dirty, marked with the desired minimum file size (in bytes) after write-back.
  • On success, clears the writeback_size to None.

If the slot is clean, this does not trigger the I/O.

Trait Implementations§

Source§

impl Drop for Slot

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Slot

§

impl !RefUnwindSafe for Slot

§

impl Send for Slot

§

impl Sync for Slot

§

impl Unpin for Slot

§

impl !UnwindSafe for Slot

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.