Skip to main content

Range

Struct Range 

Source
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

Source

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.

Source

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].

Source

pub const fn addr(&self) -> u64

The start address of the range.

Source

pub const fn size(&self) -> u64

The size of the range.

Source

pub const fn ty(&self) -> Type

The type of the range.

Source

pub const fn end(&self) -> u64

The exclusive endpoint of the range.

Source

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.

Source

pub const fn intersects(&self, other: &Range) -> bool

Determine if other intersects with self.

Intersection is type-agnostic.

Trait Implementations§

Source§

impl Clone for Range

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Range

Source§

impl Debug for Range

Source§

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

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

impl Eq for Range

Source§

impl PartialEq for Range

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Range

Source§

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.

1.0.0 (const: unstable)§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable)§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable)§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable)§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

§

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

§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

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

§

type Error = !

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

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

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.