pub struct AllocatedPages { /* private fields */ }
Expand description

Represents a range of allocated VirtualAddresses, specified in Pages.

These pages are not initially mapped to any physical memory frames, you must do that separately in order to actually use their memory; see the MappedPages type for more.

This object represents ownership of the allocated virtual pages; if this object falls out of scope, its allocated pages will be auto-deallocated upon drop.

Implementations§

Returns an empty AllocatedPages object that performs no page allocation. Can be used as a placeholder, but will not permit any real usage.

Merges the given AllocatedPages object ap into this AllocatedPages object (self). This is just for convenience and usability purposes, it performs no allocation or remapping.

The ap must be virtually contiguous and come immediately after self, that is, self.end must equal ap.start. If this condition is met, self is modified and Ok(()) is returned, otherwise Err(ap) is returned.

Splits this AllocatedPages into two separate AllocatedPages objects:

  • [beginning : at_page - 1]
  • [at_page : end]

This function follows the behavior of core::slice::split_at(), thus, either one of the returned AllocatedPages objects may be empty.

  • If at_page == self.start, the first returned AllocatedPages object will be empty.
  • If at_page == self.end + 1, the second returned AllocatedPages object will be empty.

Returns an Err containing this AllocatedPages if at_page is otherwise out of bounds.

Methods from Deref<Target = PageRange>§

Returns the [VirtualAddress] of the starting [Page] in this PageRange.

Returns the number of [Page]s 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.

Returns the size of this range in number of bytes.

Returns true if this PageRange contains the given [VirtualAddress].

Returns the offset of the given [VirtualAddress] within this PageRange, i.e., addr - self.start_address().

If the given addr is not covered by this range of [Page]s, this returns None.

Examples

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

Returns the [VirtualAddress] at the given offset into this PageRangewithin this PageRange, i.e., addr - self.start_address().

If the given offset is not within this range of [Page]s, this returns None.

Examples

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

Returns a new separate PageRange that is extended to include the given [Page].

Returns an inclusive PageRange representing the [Page]s that overlap across this PageRange and the given other PageRange.

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

Methods from Deref<Target = RangeInclusive<Page>>§

Returns the lower bound of the range (inclusive).

When using an inclusive range for iteration, the values of start() and end() are unspecified after the iteration ended. To determine whether the inclusive range is empty, use the is_empty() method instead of comparing start() > end().

Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.

Examples
assert_eq!((3..=5).start(), &3);

Returns the upper bound of the range (inclusive).

When using an inclusive range for iteration, the values of start() and end() are unspecified after the iteration ended. To determine whether the inclusive range is empty, use the is_empty() method instead of comparing start() > end().

Note: the value returned by this method is unspecified after the range has been iterated to exhaustion.

Examples
assert_eq!((3..=5).end(), &5);

Returns true if item is contained in the range.

Examples
assert!(!(3..=5).contains(&2));
assert!( (3..=5).contains(&3));
assert!( (3..=5).contains(&4));
assert!( (3..=5).contains(&5));
assert!(!(3..=5).contains(&6));

assert!( (3..=3).contains(&3));
assert!(!(3..=2).contains(&3));

assert!( (0.0..=1.0).contains(&1.0));
assert!(!(0.0..=1.0).contains(&f32::NAN));
assert!(!(0.0..=f32::NAN).contains(&0.0));
assert!(!(f32::NAN..=1.0).contains(&1.0));

This method always returns false after iteration has finished:

let mut r = 3..=5;
assert!(r.contains(&3) && r.contains(&5));
for _ in r.by_ref() {}
// Precise field values are unspecified here
assert!(!r.contains(&3) && !r.contains(&5));

Returns true if the range contains no items.

Examples
assert!(!(3..=5).is_empty());
assert!(!(3..=3).is_empty());
assert!( (3..=2).is_empty());

The range is empty if either side is incomparable:

assert!(!(3.0..=5.0).is_empty());
assert!( (3.0..=f32::NAN).is_empty());
assert!( (f32::NAN..=5.0).is_empty());

This method returns true after iteration has finished:

let mut r = 3..=5;
for _ in r.by_ref() {}
// Precise field values are unspecified here
assert!(r.is_empty());

Trait Implementations§

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.