Struct hal::memory::VAddr

source ·
pub struct VAddr(/* private fields */);
Expand description

Represents a virtual address. On architectures that have extra requirements for canonical virtual addresses (e.g. x86_64 requiring correct sign-extension in high bits), these requirements are always enforced.

Implementations§

source§

impl VAddr

source

pub const fn new(address: usize) -> VAddr

Construct a new VAddr. This will canonicalise the given value.

source

pub const fn ptr<T>(self) -> *const T

source

pub const fn mut_ptr<T>(self) -> *mut T

source

pub const fn canonicalise(self) -> VAddr

Canonicalise this virtual address. On x86_64 and RV64-Sv48, that involves making sure that bits 48..64 are sign extended from bit 47.

source

pub fn align_down(self, align: usize) -> VAddr

Align this address to the given alignment, moving downwards if this is not already aligned. align must be 0 or a power-of-two.

source

pub fn align_up(self, align: usize) -> VAddr

Align this address to the given alignment, moving upwards if this is not already aligned. align must be 0 or a power-of-two.

source

pub fn is_aligned(self, align: usize) -> bool

source

pub fn checked_add(self, rhs: usize) -> Option<Self>

source

pub fn checked_sub(self, rhs: usize) -> Option<Self>

Trait Implementations§

source§

impl Add<usize> for VAddr

§

type Output = VAddr

The resulting type after applying the + operator.
source§

fn add(self, rhs: usize) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<usize> for VAddr

source§

fn add_assign(&mut self, rhs: usize)

Performs the += operation. Read more
source§

impl Clone for VAddr

source§

fn clone(&self) -> VAddr

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 Debug for VAddr

source§

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

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

impl Default for VAddr

source§

fn default() -> VAddr

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

impl<T> From<*const T> for VAddr

source§

fn from(ptr: *const T) -> VAddr

Converts to this type from the input type.
source§

impl<T> From<*mut T> for VAddr

source§

fn from(ptr: *mut T) -> VAddr

Converts to this type from the input type.
source§

impl From<VAddr> for usize

source§

fn from(address: VAddr) -> usize

Converts to this type from the input type.
source§

impl LowerHex for VAddr

source§

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

Formats the value using the given formatter.
source§

impl Ord for VAddr

source§

fn cmp(&self, other: &VAddr) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for VAddr

source§

fn eq(&self, other: &VAddr) -> 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 PartialOrd for VAddr

source§

fn partial_cmp(&self, other: &VAddr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<usize> for VAddr

§

type Output = VAddr

The resulting type after applying the - operator.
source§

fn sub(self, rhs: usize) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<usize> for VAddr

source§

fn sub_assign(&mut self, rhs: usize)

Performs the -= operation. Read more
source§

impl UpperHex for VAddr

source§

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

Formats the value using the given formatter.
source§

impl Copy for VAddr

source§

impl Eq for VAddr

source§

impl StructuralEq for VAddr

source§

impl StructuralPartialEq for VAddr

Auto Trait Implementations§

§

impl RefUnwindSafe for VAddr

§

impl Send for VAddr

§

impl Sync for VAddr

§

impl Unpin for VAddr

§

impl UnwindSafe for VAddr

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.