PageRef

Struct PageRef 

Source
pub struct PageRef<'a> {
    kva: Kva,
    _lt: PhantomData<&'a ()>,
}
Expand description

A reference of a memory page.

PageRef represents a borrowed reference to a kernel virtual address (Kva) that maps to a memory.

§Usage

This struct is useful for safely accessing mapped kernel pages without requiring ownership transfers. The lifetime parameter 'a ensures that the reference does not outlive the memory it points to.

Fields§

§kva: Kva§_lt: PhantomData<&'a ()>

Implementations§

Source§

impl PageRef<'_>

Source

pub unsafe fn from_pa(pa: Pa) -> Self

Build a page refernce from physical address.

§Safety

Pa must be held by a other object.

Source

pub fn into_page(&self) -> Page

Increase the page reference count corresponding to.

Source

pub fn kva(&self) -> Kva

Get the kernel virtual address of this page.

§Returns
  • The kernel virtual address (Kva) of the page.
§Example:
let kva = page.kva(); // Get the kernel virtual address
Source

pub fn pa(&self) -> Pa

Get the physical address of this page.

§Returns
  • The physical address (Pa) of the page.
§Example:
let pa = page.pa(); // Get the physical address
Source

pub fn inner(&self) -> &[u8]

Get a reference to the underlying slice of the page (read-only).

This method allows access to the contents of the page as a byte slice. The caller can read from the page’s memory, but cannot modify it.

§Returns
  • A reference to the byte slice representing the contents of the page.
§Example:
let slice = page.inner(); // Get read-only access to the page's content
Source

pub fn inner_mut(&mut self) -> &mut [u8]

Get a mutable reference to the underlying slice of the page.

This method allows modification of the contents of the page as a byte slice. The caller can read from and write to the page’s memory.

§Returns
  • A mutable reference to the byte slice representing the contents of the page.
§Example:
let slice = page.inner_mut();

Auto Trait Implementations§

§

impl<'a> Freeze for PageRef<'a>

§

impl<'a> RefUnwindSafe for PageRef<'a>

§

impl<'a> Send for PageRef<'a>

§

impl<'a> Sync for PageRef<'a>

§

impl<'a> Unpin for PageRef<'a>

§

impl<'a> UnwindSafe for PageRef<'a>

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.