Struct image_texel::layout::StridedBytes
source · [−]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
sourceimpl 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
sourceimpl Clone for StridedBytes
impl Clone for StridedBytes
sourcefn clone(&self) -> StridedBytes
fn clone(&self) -> StridedBytes
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: StridedLayout> Decay<T> for StridedBytes
impl<T: StridedLayout> Decay<T> for StridedBytes
sourceimpl From<&'_ StridedBytes> for StrideSpec
impl From<&'_ StridedBytes> for StrideSpec
sourcefn from(layout: &StridedBytes) -> Self
fn from(layout: &StridedBytes) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<StridedBytes> for StridedBytes
impl PartialEq<StridedBytes> for StridedBytes
sourcefn eq(&self, other: &StridedBytes) -> bool
fn eq(&self, other: &StridedBytes) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &StridedBytes) -> bool
fn ne(&self, other: &StridedBytes) -> bool
This method tests for !=
.
sourceimpl StridedLayout for StridedBytes
impl StridedLayout for StridedBytes
sourcefn strided(&self) -> StridedBytes
fn strided(&self) -> StridedBytes
The valid strided specification of this layout. Read more
sourceimpl<P> TryMend<StridedBytes> for Texel<P>
impl<P> TryMend<StridedBytes> for Texel<P>
Try to use the matrix with a specific pixel type.
type Into = Strides<P>
type Err = MismatchedPixelError
fn try_mend(self, matrix: &StridedBytes) -> Result<Strides<P>, Self::Err>
impl Copy for StridedBytes
impl Eq for StridedBytes
impl StructuralEq for StridedBytes
impl StructuralPartialEq for StridedBytes
Auto Trait Implementations
impl RefUnwindSafe for StridedBytes
impl Send for StridedBytes
impl Sync for StridedBytes
impl Unpin for StridedBytes
impl UnwindSafe for StridedBytes
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more