Struct Allocation

Source
pub struct Allocation { /* private fields */ }
Expand description

Represents an allocation of 1 or more pages of memory

Implementations§

Source§

impl Allocation

Source

pub fn try_new(pages: usize) -> Result<Self>

Creates a new allocation with a certain number of pages, returning an error on allocation failure

§Panics

Panics when pages == 0

§Errors

When allocation fails, instead of handling allocation error in the usual way by aborting, it will return an io::Error containing the OS error

Source

pub fn new(pages: usize) -> Self

Crates a new allocation with a certain number of pages

§Panics

Panics when pages == 0

Source

pub fn free(self) -> Result<()>

Frees allocation memory

§Errors

When freeing memory failed, instead of handling free error in the usual way by aborting, it will return an io::Error containing the OS error

Source

pub const fn pages(&self) -> usize

Gets the number of pages this allocation represents

Source

pub fn as_ptr(&self) -> *const u8

Returns a raw pointer to the allocation’s buffer

The caller must ensure the data is readable/writable before trying to access the data

Source§

impl Allocation

Source

pub fn try_into_pages_mut(self) -> Result<MutPages, IntoPagesError<Self>>

Converts this Allocation into MutPages

§Errors

Will error if protecting the pages fails, error object contains this Allocation.

Source§

impl Allocation

Source

pub fn try_into_pages(self) -> Result<Pages, IntoPagesError<Self>>

Converts this Allocation into Pages

§Errors

Will error if protecting the pages fails, error object contains this Allocation.

Source§

impl Allocation

Source

pub fn try_into_pages_inaccessible( self, ) -> Result<InaccessiblePages, IntoPagesError<Self>>

Converts this Allocation into InaccessiblePages

§Errors

Will error if protecting the pages fails, error object contains this Allocation.

Trait Implementations§

Source§

impl Debug for Allocation

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Allocation

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl TryFrom<Allocation> for InaccessiblePages

Source§

type Error = IntoPagesError<Allocation>

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

fn try_from(value: Allocation) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Allocation> for MutPages

Source§

type Error = IntoPagesError<Allocation>

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

fn try_from(value: Allocation) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Allocation> for Pages

Source§

type Error = IntoPagesError<Allocation>

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

fn try_from(value: Allocation) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<InaccessiblePages> for Allocation

Source§

type Error = InaccessiblePages

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

fn try_from(value: InaccessiblePages) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<MutPages> for Allocation

Source§

type Error = MutPages

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

fn try_from(value: MutPages) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Pages> for Allocation

Source§

type Error = Pages

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

fn try_from(value: Pages) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Send for Allocation

Source§

impl Sync for Allocation

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

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.