Trait AnyPages

Source
pub trait AnyPages: Sealed {
    // Required methods
    fn start(&self) -> usize;
    fn end(&self) -> usize;
    fn accessibility(&self) -> Accessibility;
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn into_pages_type(self) -> PagesType;
    fn allocation(&self) -> &Allocation;
    fn as_ptr(&self) -> *const u8;

    // Provided methods
    fn pages(&self) -> usize { ... }
    fn len_bytes(&self) -> usize { ... }
}
Expand description

Common trait of all types of pages Note: This trait is sealed as assumptions are made about the implementors that allow properties to be safe. It would not make sense to create your own pages object which implements this trait.

Required Methods§

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 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 allocation(&self) -> &Allocation

Gets an immutable reference to the underlying Allocation

Source

fn as_ptr(&self) -> *const u8

Returns a raw pointer to the page(s)

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

Provided Methods§

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

Implementations§

Source§

impl dyn AnyPages

Source

pub fn downcast_ref<T: AnyPages + 'static>(&self) -> Option<&T>

Downcasts &dyn AnyPages into &T: AnyPages

Source

pub fn downcast_mut<T: AnyPages + 'static>(&mut self) -> Option<&mut T>

Downcasts &mut dyn AnyPages into &mut T: AnyPages

Implementors§