Struct voladdress::VolAddress [−][src]
A volatile address.
This type stores a memory address and provides ergonomic volatile access to said memory address.
Generic Parameters
T
: The type of the value stored at the address.- The target type type must impl
Copy
for reading and writing to be allowed.
- The target type type must impl
R
: If the address is readable.- If
R=Safe
then you can safely read from the address. - If
R=Unsafe
then you can unsafely read from the address. - Otherwise you cannot read from the address.
- If
W
: If the address is writable.- If
W=Safe
then you can safely write to the address. - If
W=Unsafe
then you can unsafely write to the address. - Otherwise you cannot write to the address.
- If
The VolAddress
type is intended to represent a single value of a T
type
that is the size of a single machine register (or less).
- If there’s an array of contiguous
T
values you want to model, consider usingVolBlock
instead. - If there’s a series of strided
T
values you want to model, consider usingVolSeries
instead. - If the
T
type is larger than a single machine register it’s probably not a good fit for theVolAddress
abstraction.
Safety
This type’s safety follows the “unsafe creation, then safe use” strategy.
- Validity Invariant: The address of a
VolAddress
must always be non-zero, or you will instantly trigger UB. - Safety Invariant: The address of a
VolAddress
must be an aligned and legal address for aT
type value (with correctR
andW
permissions) within the device’s memory space, otherwise theread
andwrite
methods will trigger UB when called.
Implementations
impl<T, R, W> VolAddress<T, R, W>
[src]
#[must_use]pub const unsafe fn new(address: usize) -> Self
[src]
#[must_use]pub const unsafe fn cast<Z>(self) -> VolAddress<Z, R, W>
[src]
#[must_use]pub const fn as_usize(self) -> usize
[src]
Converts the VolAddress
back into a normal usize
value.
#[must_use]pub const unsafe fn add(self, count: usize) -> Self
[src]
Advances the pointer by the given number of positions (usize
).
Shorthand for addr.offset(count as isize)
This is intended to basically work like <*mut T>::wrapping_add
.
Safety
- As per the type docs
#[must_use]pub const unsafe fn sub(self, count: usize) -> Self
[src]
Reverses the pointer by the given number of positions (usize
).
Shorthand for addr.offset((count as isize).wrapping_neg())
This is intended to basically work like <*mut T>::wrapping_sub
.
Safety
- As per the type docs
#[must_use]pub const unsafe fn offset(self, count: isize) -> Self
[src]
Offsets the address by the given number of positions (isize
).
This is intended to basically work like <*mut T>::wrapping_offset
.
Safety
- As per the type docs
impl<T, W> VolAddress<T, Safe, W> where
T: Copy,
[src]
T: Copy,
impl<T, W> VolAddress<T, Unsafe, W> where
T: Copy,
[src]
T: Copy,
#[must_use]pub unsafe fn read(self) -> T
[src]
Volatile reads the current value of A
.
Safety
- The safety rules of reading this address depend on the device. Consult your hardware manual.
impl<T, R> VolAddress<T, R, Safe> where
T: Copy,
[src]
T: Copy,
impl<T, R> VolAddress<T, R, Unsafe> where
T: Copy,
[src]
T: Copy,
pub unsafe fn write(self, t: T)
[src]
Volatile writes a new value to A
.
Safety
- The safety rules of reading this address depend on the device. Consult your hardware manual.
Trait Implementations
impl<T, R, W> Clone for VolAddress<T, R, W>
[src]
#[must_use]fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T, R, W> Copy for VolAddress<T, R, W>
[src]
impl<T, R, W> Debug for VolAddress<T, R, W>
[src]
impl<T: Eq, R: Eq, W: Eq> Eq for VolAddress<T, R, W>
[src]
impl<T: Hash, R: Hash, W: Hash> Hash for VolAddress<T, R, W>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord, R: Ord, W: Ord> Ord for VolAddress<T, R, W>
[src]
fn cmp(&self, other: &VolAddress<T, R, W>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq, R: PartialEq, W: PartialEq> PartialEq<VolAddress<T, R, W>> for VolAddress<T, R, W>
[src]
fn eq(&self, other: &VolAddress<T, R, W>) -> bool
[src]
fn ne(&self, other: &VolAddress<T, R, W>) -> bool
[src]
impl<T: PartialOrd, R: PartialOrd, W: PartialOrd> PartialOrd<VolAddress<T, R, W>> for VolAddress<T, R, W>
[src]
fn partial_cmp(&self, other: &VolAddress<T, R, W>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T, R, W> StructuralEq for VolAddress<T, R, W>
[src]
impl<T, R, W> StructuralPartialEq for VolAddress<T, R, W>
[src]
Auto Trait Implementations
impl<T, R, W> Send for VolAddress<T, R, W> where
R: Send,
T: Send,
W: Send,
R: Send,
T: Send,
W: Send,
impl<T, R, W> Sync for VolAddress<T, R, W> where
R: Sync,
T: Sync,
W: Sync,
R: Sync,
T: Sync,
W: Sync,
impl<T, R, W> Unpin for VolAddress<T, R, W> where
R: Unpin,
T: Unpin,
W: Unpin,
R: Unpin,
T: Unpin,
W: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,