Struct Pages

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

Represents a page, or range of pages with Immutable accessibility

Implementations§

Source§

impl Pages

Source

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

Converts this MutPages into Pages, updating the protection of the underlying pages

§Errors

Will error if protecting the pages fails, error object contains self.

Source§

impl Pages

Source

pub fn split(self, index: usize) -> Result<(Self, Self), Self>

Splits this Pages into two consecutive Pages at a given index

§Errors

If the index would result in one half of the split having 0 size, this will return itself back out as an error

Source

pub fn set_locked(&mut self, locked: bool) -> Result<()>

Sets whether the pages represented by this Pages is locked into memory or not. See mlock(2)

§Errors

If the OS returns an error from the mlock or munlock syscall, it is returned as an io::Error

Source

pub fn join<const C: usize>( parts: [PagesType; C], ) -> Result<Self, JoinError<[PagesType; C]>>

Joins two or more contiguous pages from the same allocation into a single object, updating the protection of the memory region in a single syscall if nessassary.

§Errors

See JoinErrorKind docs. Will return a JoinError containing the input PagesTypes and a JoinErrorKind containing what went wrong.

Source

pub fn join_vec( parts: Vec<PagesType>, ) -> Result<Self, JoinError<Vec<PagesType>>>

Joins two or more contiguous pages from the same allocation into a single object, updating the protection of the memory region in a single syscall if nessassary. Accepts a Vec as an input rather than a const size array like Self::join

§Errors

See JoinErrorKind docs. Will return a JoinError containing the input PagesTypes and a JoinErrorKind containing what went wrong.

Source

pub fn try_into_allocation(self) -> Result<Allocation, Self>

Converts this Pages into an Allocation. If the only reference that still exists to pages inside the allocation is through self, then this will succeed. Other references can be removed by dropping other pages objects or by joining them together through Self::join or Self::join_vec.

§Errors

Will return Self as an error if other references to the allocation still exist.

Source§

impl Pages

Source

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

Converts this InaccessiblePages into Pages, updating the protection of the underlying pages

§Errors

Will error if protecting the pages fails, error object contains self.

Trait Implementations§

Source§

impl AnyPages for Pages

Source§

fn start(&self) -> usize

Gets the start index of the page of the underlying allocation which this object references
Source§

fn end(&self) -> usize

Gets the end index of the page of the underlying allocation which this object references
Source§

fn accessibility(&self) -> Accessibility

Gets the Accessibility of this pages object
Source§

fn allocation(&self) -> &Allocation

Gets an immutable reference to the underlying Allocation
Source§

fn as_any(&self) -> &dyn Any

Gets this pages object as a &dyn Any object for reference downcasting
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Gets this pages object as a &mut dyn Any object for reference downcasting
Source§

fn into_pages_type(self) -> PagesType

Gets this pages object as a PagesType enum to allow pattern matching and unwrapping on accessibility
Source§

fn as_ptr(&self) -> *const u8

Returns a raw pointer to the page(s) Read more
Source§

fn pages(&self) -> usize

Gets the number of pages this pages object references
Source§

fn len_bytes(&self) -> usize

Gets the number of bytes this pages object references. This is implemented as AnyPages::pages multiplied by the page size
Source§

impl Debug for Pages

Source§

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

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

impl From<Pages> for PagesType

Source§

fn from(value: Pages) -> PagesType

Converts to this type from the input type.
Source§

impl SlicePages for Pages

Source§

fn slice(&self) -> &[u8]

Gets a slice of the raw bytes of the pages represented by this pages object
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 Pages

Source§

type Error = IntoPagesError<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 Pages

Source§

type Error = IntoPagesError<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 TryFrom<Pages> for InaccessiblePages

Source§

type Error = IntoPagesError<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 TryFrom<Pages> for MutPages

Source§

type Error = IntoPagesError<Pages>

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

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

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Pages

§

impl RefUnwindSafe for Pages

§

impl Send for Pages

§

impl Sync for Pages

§

impl Unpin for Pages

§

impl UnwindSafe for Pages

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.