pub struct FrameRange<P: PageSize = Page4K>(/* private fields */);
Expand description

A range of Frames that are contiguous in physical memory.

Implementations§

source§

impl FrameRange<Page4K>

source

pub const fn from_phys_addr( starting_addr: PhysicalAddress, size_in_bytes: usize ) -> FrameRange

A convenience method for creating a new FrameRange that spans all Frames from the given PhysicalAddress to an end bound based on the given size.

source§

impl<P: PageSize> FrameRange<P>

source

pub const fn empty() -> Self

Creates an empty FrameRange that will always yield None when iterated.

source

pub const fn new(start: Frame<P>, end: Frame<P>) -> FrameRange<P>

Creates a new range of Frames that spans from start to end, both inclusive bounds.

source

pub const fn start(&self) -> &Frame<P>

Returns the starting Frame in this FrameRange.

source

pub const fn end(&self) -> &Frame<P>

Returns the ending Frame in this FrameRange.

source

pub const fn start_address(&self) -> PhysicalAddress

Returns the PhysicalAddress of the starting Frame in this FrameRange.

source

pub const fn size_in_frames(&self) -> usize

Returns the number of Frames covered by this iterator.

Use this instead of Iterator::count() method. This is instant, because it doesn’t need to iterate over each entry, unlike normal iterators.

source

pub const fn size_in_bytes(&self) -> usize

Returns the size of this range in bytes.

source

pub const fn contains_address(&self, addr: PhysicalAddress) -> bool

Returns true if this FrameRange contains the given PhysicalAddress.

source

pub const fn offset_of_address(&self, addr: PhysicalAddress) -> Option<usize>

Returns the offset of the given PhysicalAddress within this FrameRange, i.e., addr - self.start_address().

If the given addr is not covered by this range of Frames, this returns None.

Examples

If the range covers addresses 0x2000 to 0x4000, then offset_of_address(0x3500) would return Some(0x1500).

source

pub const fn address_at_offset(&self, offset: usize) -> Option<PhysicalAddress>

Returns the PhysicalAddress at the given offset into this FrameRangewithin this FrameRange, i.e., self.start_address() + offset.

If the given offset is not within this range of Frames, this returns None.

Examples

If the range covers addresses 0x2000 through 0x3FFF, then address_at_offset(0x1500) would return Some(0x3500), and address_at_offset(0x2000) would return None.

source

pub fn to_extended(&self, to_include: Frame<P>) -> FrameRange<P>

Returns a new separate FrameRange that is extended to include the given Frame.

source

pub fn contains_range(&self, other: &FrameRange<P>) -> bool

Returns true if the other FrameRange is fully contained within this FrameRange.

source

pub fn overlap(&self, other: &FrameRange<P>) -> Option<FrameRange<P>>

Returns an inclusive FrameRange representing the Frames that overlap across this FrameRange and the given other FrameRange.

If there is no overlap between the two ranges, None is returned.

source

pub fn into_4k_frames(self) -> FrameRange<Page4K>

Converts this range of Frames into an identical 4K-sized range.

Methods from Deref<Target = RangeInclusive<Frame<P>>>§

source

pub fn start(&self) -> &Idx

Returns the lower bound of the range (inclusive).

source

pub fn end(&self) -> &Idx

Returns the upper bound of the range (inclusive).

source

pub fn is_empty(&self) -> bool

Returns true if the range contains no items.

source

pub fn iter(&self) -> RangeInclusiveIterator<Idx>

Returns an iterator with the same start and end values as the range.

source

pub fn contains<U>(&self, item: &U) -> boolwhere Idx: PartialOrd<U>, U: PartialOrd<Idx> + ?Sized,

Returns true if item is contained in the range.

Trait Implementations§

source§

impl<P: Clone + PageSize> Clone for FrameRange<P>

source§

fn clone(&self) -> FrameRange<P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<P: PageSize> Debug for FrameRange<P>

source§

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

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

impl<P: PageSize> Default for FrameRange<P>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<P: PageSize> Deref for FrameRange<P>

§

type Target = RangeInclusive<Frame<P>>

The resulting type after dereferencing.
source§

fn deref(&self) -> &RangeInclusive<Frame<P>>

Dereferences the value.
source§

impl DerefMut for FrameRange

source§

fn deref_mut(&mut self) -> &mut RangeInclusive<Frame>

Mutably dereferences the value.
source§

impl From<FrameRange<Page1G>> for FrameRange<Page4K>

source§

fn from(r: FrameRange<Page1G>) -> Self

Converts to this type from the input type.
source§

impl From<FrameRange<Page2M>> for FrameRange<Page4K>

source§

fn from(r: FrameRange<Page2M>) -> Self

Converts to this type from the input type.
source§

impl<P: PageSize> IntoIterator for &FrameRange<P>

§

type Item = Frame<P>

The type of the elements being iterated over.
§

type IntoIter = RangeInclusiveIterator<Frame<P>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<P: PageSize> IntoIterator for FrameRange<P>

§

type Item = Frame<P>

The type of the elements being iterated over.
§

type IntoIter = RangeInclusiveIterator<Frame<P>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<P: PartialEq + PageSize> PartialEq<FrameRange<P>> for FrameRange<P>

source§

fn eq(&self, other: &FrameRange<P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<FrameRange<Page4K>> for FrameRange<Page1G>

§

type Error = &'static str

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

fn try_from(p: FrameRange) -> Result<Self, &'static str>

Performs the conversion.
source§

impl TryFrom<FrameRange<Page4K>> for FrameRange<Page2M>

§

type Error = &'static str

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

fn try_from(p: FrameRange) -> Result<Self, &'static str>

Performs the conversion.
source§

impl<P: Eq + PageSize> Eq for FrameRange<P>

source§

impl<P: PageSize> StructuralEq for FrameRange<P>

source§

impl<P: PageSize> StructuralPartialEq for FrameRange<P>

Auto Trait Implementations§

§

impl<P> RefUnwindSafe for FrameRange<P>where P: RefUnwindSafe,

§

impl<P> Send for FrameRange<P>where P: Send,

§

impl<P> Sync for FrameRange<P>where P: Sync,

§

impl<P> Unpin for FrameRange<P>where P: Unpin,

§

impl<P> UnwindSafe for FrameRange<P>where P: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.