pub trait AsPixels<PixelType> {
// Required methods
fn as_pixels(&self) -> &[PixelType];
fn as_pixels_mut(&mut self) -> &mut [PixelType];
}Expand description
Use ::bytemuck::cast_slice() instead.
Casts a slice of bytes into a slice of pixels, e.g. [u8] to [RGB8].
See also FromSlice
Required Methods§
Sourcefn as_pixels(&self) -> &[PixelType]
fn as_pixels(&self) -> &[PixelType]
Use ::bytemuck::cast_slice() instead.
Reinterpret the slice as a read-only/shared slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA).
Leftover elements are ignored if the slice isn’t evenly divisible into pixels.
Use this method only when the type is known from context.
See also FromSlice.
Sourcefn as_pixels_mut(&mut self) -> &mut [PixelType]
fn as_pixels_mut(&mut self) -> &mut [PixelType]
Use ::bytemuck::cast_slice_mut() instead.
Reinterpret the slice as a mutable/exclusive slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA).
Leftover elements are ignored if the slice isn’t evenly divisible into pixels.
Use this method only when the type is known from context.
See also FromSlice.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".