Struct voladdress::VolBlock
source · 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§
source§impl<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.
sourcepub fn as_slice_mut_ptr(self) -> *mut [T]
pub fn as_slice_mut_ptr(self) -> *mut [T]
Converts the VolBlock
into a mut slice 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> ⓘ
pub const fn iter(self) -> VolBlockIter<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> ⓘ
pub fn iter_range<RB: RangeBounds<usize>>(self, r: RB) -> VolBlockIter<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.
Trait Implementations§
source§impl<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 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq, R: PartialEq, W: PartialEq, const C: usize> PartialEq for VolBlock<T, R, W, C>
impl<T: PartialEq, R: PartialEq, W: PartialEq, const C: usize> PartialEq for VolBlock<T, R, W, C>
source§impl<T: PartialOrd, R: PartialOrd, W: PartialOrd, const C: usize> PartialOrd for VolBlock<T, R, W, C>
impl<T: PartialOrd, R: PartialOrd, W: PartialOrd, const C: usize> PartialOrd for VolBlock<T, R, W, C>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more