Skip to main content

PageRangeBox

Struct PageRangeBox 

Source
pub struct PageRangeBox<A: PageRangeAllocator>(/* private fields */);

Implementations§

Source§

impl<A: PageRangeAllocator> PageRangeBox<A>

Source

pub fn new(layout: PageLayout) -> Result<Self, AllocError>

Source

pub unsafe fn from_raw(range: PageRange) -> Self

Source

pub fn into_raw(b: Self) -> PageRange

Methods from Deref<Target = PageRange>§

Source

pub fn start(self) -> usize

Returns the start address of this page range.

§Examples
use free_list::PageRange;

let range = PageRange::new(0x1000, 0x5000).unwrap();
assert_eq!(range.start(), 0x1000);
Source

pub fn end(self) -> usize

Returns the end address of this page range.

§Examples
use free_list::PageRange;

let range = PageRange::new(0x1000, 0x5000).unwrap();
assert_eq!(range.end(), 0x5000);
Source

pub fn len(self) -> NonZero<usize>

Returns the length of this page range in bytes.

§Examples
use free_list::PageRange;

let range = PageRange::new(0x1000, 0x5000).unwrap();
assert_eq!(range.len().get(), 0x4000);
Source

pub fn pages(self) -> NonZero<usize>

Returns the length of this page range in pages of size PAGE_SIZE.

§Examples
use free_list::PageRange;

let range = PageRange::new(0x1000, 0x5000).unwrap();
assert_eq!(range.pages().get(), 4);
Source

pub fn overlaps(self, other: PageRange) -> bool

Returns true if self overlaps with other.

This property is exclusive with PageRange::touches.

§Examples
use free_list::PageRange;

let a = PageRange::new(0x1000, 0x5000).unwrap();
let b = PageRange::new(0x3000, 0x7000).unwrap();
assert!(a.overlaps(b));
Source

pub fn touches(self, other: PageRange) -> bool

Returns true if self touches other.

This is exclusive with PageRange::overlaps.

§Examples
use free_list::PageRange;

let a = PageRange::new(0x1000, 0x5000).unwrap();
let b = PageRange::new(0x5000, 0x9000).unwrap();
assert!(a.touches(b));
Source

pub fn contains(self, other: PageRange) -> bool

Returns true if self contains other.

§Examples
use free_list::PageRange;

let a = PageRange::new(0x1000, 0x5000).unwrap();
let b = PageRange::new(0x1000, 0x3000).unwrap();
assert!(a.contains(b));
Source

pub fn fit(self, layout: PageLayout) -> Option<PageRange>

Returns the first page range that is contained in self and satisfies layout.

§Examples
use free_list::{PageLayout, PageRange};

let range = PageRange::new(0x1000, 0x5000).unwrap();
let layout = PageLayout::from_size_align(0x3000, 0x2000).unwrap();
let expected = PageRange::new(0x2000, 0x5000).unwrap();
assert_eq!(range.fit(layout), Some(expected));
Source

pub fn and(self, rhs: PageRange) -> Option<PageRange>

Returns the intersection of self and rhs as a new PageRange if non-empty.

§Examples
use free_list::PageRange;

let lhs = PageRange::new(0x1000, 0x3000).unwrap();
let rhs = PageRange::new(0x2000, 0x5000).unwrap();
let expected = PageRange::new(0x2000, 0x3000).unwrap();
assert_eq!(lhs.and(rhs), Some(expected));

Trait Implementations§

Source§

impl<A: PageRangeAllocator> Deref for PageRangeBox<A>

Source§

type Target = PageRange

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<A: PageRangeAllocator> Drop for PageRangeBox<A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<A> Freeze for PageRangeBox<A>
where PhantomData<A>: Freeze,

§

impl<A> RefUnwindSafe for PageRangeBox<A>

§

impl<A> Send for PageRangeBox<A>
where PhantomData<A>: Send,

§

impl<A> Sync for PageRangeBox<A>
where PhantomData<A>: Sync,

§

impl<A> Unpin for PageRangeBox<A>
where PhantomData<A>: Unpin,

§

impl<A> UnsafeUnpin for PageRangeBox<A>

§

impl<A> UnwindSafe for PageRangeBox<A>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V