Struct voladdress::VolBlock
source · #[repr(transparent)]pub struct VolBlock<T, R, W, const C: usize> { /* private fields */ }
Expand description
A volatile memory block.
This is intended to model when a portion of memory is an array of identical
values in a row, such as a block of 256 u16
values in a row.
Generic Parameters
T
/R
/W
: These parameters are applied to theVolAddress
type returned when accessing the block in any way (indexing, iteration, etc).C
: the count of elements in the block.
Safety
- This type stores a base
VolAddress
internally, and so you must follow all of those safety rules. Notably, the base address must never be zero. - The address space must legally contain
C
contiguous values of theT
type, starting from the base address. - The memory block must not wrap around past the end of the address space.
Implementations
sourceimpl<T, R, W, const C: usize> VolBlock<T, R, W, C>
impl<T, R, W, const C: usize> VolBlock<T, R, W, C>
sourcepub const fn as_usize(self) -> usize
pub const fn as_usize(self) -> usize
Converts the VolBlock
the usize
for the start of the block.
sourcepub const fn as_ptr(self) -> *const T
pub const fn as_ptr(self) -> *const T
Converts the VolBlock
into an individual const pointer.
This should usually only be used when you need to call a foreign function that expects a pointer.
sourcepub const fn as_mut_ptr(self) -> *mut T
pub const fn as_mut_ptr(self) -> *mut T
Converts the VolBlock
into an individual mut pointer.
This should usually only be used when you need to call a foreign function that expects a pointer.
sourcepub fn as_slice_ptr(self) -> *const [T]
pub fn as_slice_ptr(self) -> *const [T]
Converts the VolBlock
into a const slice pointer.
This should usually only be used when you need to call a foreign function that expects a pointer.
sourcepub fn as_slice_mut_ptr(self) -> *mut [T]
pub fn as_slice_mut_ptr(self) -> *mut [T]
Converts the VolBlock
into an individual mut pointer.
This should usually only be used when you need to call a foreign function that expects a pointer.
sourcepub const fn index(self, i: usize) -> VolAddress<T, R, W>
pub const fn index(self, i: usize) -> VolAddress<T, R, W>
Indexes to the i
th position of the memory block.
Panics
- If the index is out of bounds this will panic.
sourcepub const fn get(self, i: usize) -> Option<VolAddress<T, R, W>>
pub const fn get(self, i: usize) -> Option<VolAddress<T, R, W>>
Gets the address of the i
th position, if it’s in bounds.
sourcepub const fn iter(self) -> VolBlockIter<T, R, W>ⓘNotable traits for VolBlockIter<T, R, W>impl<T, R, W> Iterator for VolBlockIter<T, R, W> type Item = VolAddress<T, R, W>;
pub const fn iter(self) -> VolBlockIter<T, R, W>ⓘNotable traits for VolBlockIter<T, R, W>impl<T, R, W> Iterator for VolBlockIter<T, R, W> type Item = VolAddress<T, R, W>;
Creates an iterator over the addresses of the memory block.
sourcepub fn iter_range<RB: RangeBounds<usize>>(self, r: RB) -> VolBlockIter<T, R, W>ⓘNotable traits for VolBlockIter<T, R, W>impl<T, R, W> Iterator for VolBlockIter<T, R, W> type Item = VolAddress<T, R, W>;
pub fn iter_range<RB: RangeBounds<usize>>(self, r: RB) -> VolBlockIter<T, R, W>ⓘNotable traits for VolBlockIter<T, R, W>impl<T, R, W> Iterator for VolBlockIter<T, R, W> type Item = VolAddress<T, R, W>;
Makes an iterator over the range bounds given.
If the range given is empty then your iterator will be empty.
Panics
- If the start or end of the range are out of bounds for the block.
sourcepub const unsafe fn as_voladdress(self) -> VolAddress<[T; C], R, W>
pub const unsafe fn as_voladdress(self) -> VolAddress<[T; C], R, W>
Casts a block to an address to an equivalent sized array.
Safety
- As per the general
VolAddress
construction rules. - It is highly likely that on any device this is safe, but because of
possible strangeness with volatile side effects this is marked as an
unsafe
method.
Trait Implementations
sourceimpl<T: Ord, R: Ord, W: Ord, const C: usize> Ord for VolBlock<T, R, W, C>
impl<T: Ord, R: Ord, W: Ord, const C: usize> Ord for VolBlock<T, R, W, C>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<T: PartialEq, R: PartialEq, W: PartialEq, const C: usize> PartialEq<VolBlock<T, R, W, C>> for VolBlock<T, R, W, C>
impl<T: PartialEq, R: PartialEq, W: PartialEq, const C: usize> PartialEq<VolBlock<T, R, W, C>> for VolBlock<T, R, W, C>
sourceimpl<T: PartialOrd, R: PartialOrd, W: PartialOrd, const C: usize> PartialOrd<VolBlock<T, R, W, C>> for VolBlock<T, R, W, C>
impl<T: PartialOrd, R: PartialOrd, W: PartialOrd, const C: usize> PartialOrd<VolBlock<T, R, W, C>> for VolBlock<T, R, W, C>
sourcefn partial_cmp(&self, other: &VolBlock<T, R, W, C>) -> Option<Ordering>
fn partial_cmp(&self, other: &VolBlock<T, R, W, C>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more