Struct hal_core::VAddr

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

Implementations§

source§

impl VAddr

source

pub fn from_usize_checked(u: usize) -> Result<Self, InvalidAddress>

source

pub const unsafe fn from_usize_unchecked(u: usize) -> Self

Constructs a VAddr from an arbitrary usize value without checking if it’s valid.

Pros of this function:

  • can be used in const-eval contexts

Cons of this function:

  • “refer to ‘Safety’ section”
Safety

u can use dis function to construct invalid addresses. probably dont do that.

source

pub fn of<T: ?Sized>(pointee: &T) -> Self

source§

impl VAddr

source

pub const fn zero() -> Self

source

pub fn from_u64(u: u64) -> Self

Panics
  • If debug assertions are enabled and the address is not valid for the target architecture.
source

pub fn align_up<A: Into<usize>>(self, align: A) -> Self

Aligns self up to align.

The specified alignment must be a power of two.

Panics
  • If align is not a power of two.
  • If debug assertions are enabled and the aligned address is not valid for the target architecture.
source

pub fn align_down<A: Into<usize>>(self, align: A) -> Self

Aligns self down to align.

The specified alignment must be a power of two.

Panics
  • If align is not a power of two.
  • If debug assertions are enabled and the aligned address is not valid for the target architecture.
source

pub fn offset(self, offset: i32) -> Self

Offsets this address by offset.

If the specified offset would overflow, this function saturates instead.

source

pub fn difference(self, other: Self) -> isize

Returns the difference between self and other.

source

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

Returns true if self is aligned on the specified alignment.

source

pub fn is_aligned_for<T>(self) -> bool

Returns true if self is aligned on the alignment of the specified type.

source

pub fn as_ptr<T>(self) -> *mut T

Panics
  • If self is not aligned for a T-typed value.

Trait Implementations§

source§

impl Add<usize> for VAddr

source§

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

Offset self up by rhs.

Notes
  • The address will be offset by the minimum addressable unit of the target architecture (i.e. probably bytes), not by by units of a Rust type like {*const T, *mut T}::add.
  • Therefore, resulting address may have a different alignment from the input address.
Panics
  • If the resulting address is invalid.
§

type Output = VAddr

The resulting type after applying the + operator.
source§

impl Add for VAddr

source§

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

Add rhs bytes to this this address.

Note that the resulting address may differ in alignment from the input address!

§

type Output = VAddr

The resulting type after applying the + operator.
source§

impl AddAssign<usize> for VAddr

source§

fn add_assign(&mut self, rhs: usize)

Performs the += operation. Read more
source§

impl AddAssign for VAddr

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl Address for VAddr

source§

fn from_usize(u: usize) -> Self

Panics
  • If debug assertions are enabled and the address is not valid for the target architecture.
source§

fn as_usize(self) -> usize

source§

fn align_up<A: Into<usize>>(self, align: A) -> Self

Aligns self up to align. Read more
source§

fn align_up_for<T>(self) -> Self

Align self up to the required alignment for a value of type T. Read more
source§

fn align_down<A: Into<usize>>(self, align: A) -> Self

Aligns self down to align. Read more
source§

fn align_down_for<T>(self) -> Self

Align self down to the required alignment for a value of type T. Read more
source§

fn offset(self, offset: i32) -> Self

Offsets this address by offset. Read more
source§

fn difference(self, other: Self) -> isize

Returns the difference between self and other.
source§

fn is_aligned<A: Into<usize>>(self, align: A) -> bool

Returns true if self is aligned on the specified alignment. Read more
source§

fn is_aligned_for<T>(self) -> bool

Returns true if self is aligned on the alignment of the specified type.
source§

fn as_ptr<T>(self) -> *mut T

Panics 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 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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where 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

Performs the - operation. Read more
source§

impl Sub for VAddr

§

type Output = VAddr

The resulting type after applying the - operator.
source§

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

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

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

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

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.