pub struct Range { /* private fields */ }Expand description
A physical memory range type.
Range specifies a half open iterval of physical memory [addr, addr + size) with ty
describing the usage of this memory. It layout-compatible to zbi_mem_range_t, but with the
benefit of being able to use allocated types.
addr + size never overflows.
Implementations§
Source§impl Range
impl Range
Sourcepub const fn new(addr: u64, size: u64, ty: Type) -> Self
pub const fn new(addr: u64, size: u64, ty: Type) -> Self
Construct a new range.
If addr + size > u64::MAX, the size is reduced so there is no overflow.
Sourcepub fn slice_from_zbi_mem_ranges(ranges: &mut [MemRange]) -> &mut [Self]
pub fn slice_from_zbi_mem_ranges(ranges: &mut [MemRange]) -> &mut [Self]
Sanitize a mutable slice of zbi::MemRange in-place and view it as &mut [Range].
Sourcepub const fn align_out(&self, alignment: u64) -> Self
pub const fn align_out(&self, alignment: u64) -> Self
Align the ends of a range outward to be multiples of alignment.
The start address is rounded down and the end address is rounded up. If the end address would be larger than 2^64, we saturate it.
§Panics
Panics if alignment is not a power of two.
Sourcepub const fn intersects(&self, other: &Range) -> bool
pub const fn intersects(&self, other: &Range) -> bool
Determine if other intersects with self.
Intersection is type-agnostic.
Trait Implementations§
impl Copy for Range
impl Eq for Range
Source§impl PartialOrd for Range
impl PartialOrd for Range
Source§fn partial_cmp(&self, other: &Range) -> Option<Ordering>
fn partial_cmp(&self, other: &Range) -> Option<Ordering>
Order ranges lexicographically.
Comparisons are not type sensitive unless both the start address and size are equal to each
other, in which case different types yields a None.
impl StructuralPartialEq for Range
Auto Trait Implementations§
impl Freeze for Range
impl RefUnwindSafe for Range
impl Send for Range
impl Sync for Range
impl Unpin for Range
impl UnsafeUnpin for Range
impl UnwindSafe for Range
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DTwhere
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DTwhere
ST: ?Sized,
DT: ?Sized,
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)