pub struct StridedBytes { /* private fields */ }Expand description
A validated layout of a rectangular matrix of pixels, treated as bytes.
The invariants are that the whole layout fits into memory, additionally ensuring that all indices within have proper indices into the byte slice containing the data.
The related containers StridedBufferRef and StridedBufferMut can be utilized to setup
efficient initialization of data from different stride sources. Since they require only the
alignment according to their elements, not according to the maximum alignment, they may be used
for external data that is copied to an image.
Implementations§
Source§impl StridedBytes
impl StridedBytes
Sourcepub fn new(spec: StrideSpec) -> Result<Self, BadStrideError>
pub fn new(spec: StrideSpec) -> Result<Self, BadStrideError>
Try to create a new layout from a specification.
This fails if the specification does not describe a valid layout. The reasons for this include the element being misaligned according to the provided offsets/strides or the layout not describing a memory size expressible on the current architecture.
Sourcepub fn with_repeated_width_and_height(
element: TexelLayout,
width: usize,
height: usize,
) -> Self
pub fn with_repeated_width_and_height( element: TexelLayout, width: usize, height: usize, ) -> Self
Construct a layout with zeroed strides, repeating one element.
Sourcepub fn with_column_major(matrix: MatrixBytes) -> Self
pub fn with_column_major(matrix: MatrixBytes) -> Self
Construct from a packed matrix of elements in column major layout.
This is guaranteed to succeed and will construct the strides such that a packed column major matrix of elements at offset zero is described.
Sourcepub fn with_row_major(matrix: MatrixBytes) -> Self
pub fn with_row_major(matrix: MatrixBytes) -> Self
Construct from a packed matrix of elements in row major layout.
This is guaranteed to succeed and will construct the strides such that a packed row major matrix of elements at offset zero is described.
Sourcepub fn spec(&self) -> StrideSpec
pub fn spec(&self) -> StrideSpec
Get the specification of this matrix.
Sourcepub fn shrink_element(&mut self, new: TexelLayout)
pub fn shrink_element(&mut self, new: TexelLayout)
Shrink the element’s size or alignment.
This is always valid since the new layout is strictly contained within the old one.
Trait Implementations§
Source§impl Clone for StridedBytes
impl Clone for StridedBytes
Source§fn clone(&self) -> StridedBytes
fn clone(&self) -> StridedBytes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StridedBytes
Source§impl<T: StridedLayout> Decay<T> for StridedBytes
impl<T: StridedLayout> Decay<T> for StridedBytes
impl Eq for StridedBytes
Source§impl From<&StridedBytes> for StrideSpec
impl From<&StridedBytes> for StrideSpec
Source§fn from(layout: &StridedBytes) -> Self
fn from(layout: &StridedBytes) -> Self
Source§impl PartialEq for StridedBytes
impl PartialEq for StridedBytes
Source§fn eq(&self, other: &StridedBytes) -> bool
fn eq(&self, other: &StridedBytes) -> bool
self and other values to be equal, and is used by ==.